if($(".copylink").length){ var url_short = MAC.Url; var clipboard = new Clipboard('.copylink', { text: function() { return url_short; } }); clipboard.on('success', function(e) { alert("地址复制成功,赶快分享给小伙伴吧!"); }); }