https://segmentfault.com/a/1190000020651289?utm_source=tag-newest
$("body").on("click",".index_gift_copy",function(){ var index = $(".index_gift_copy").index(this); $(".index_gift_copy").eq(index).attr("data-clipboard-text",$(".index_gift_value").eq(index).val());
var clipboard = new Clipboard(‘.index_gift_copy‘); clipboard.on(‘success‘, function(e) { console.log("复制成功"); }); clipboard.on(‘error‘, function(e) { console.log("复制失败"); }); })