今天遇到了ZeroClipboard必须点击两次才能复制的问题,记录一下,贴上正确的复制代码。
var clip = new ZeroClipboard($('#copy_btn'));
ZeroClipboard.config({
forceHandCursor : true,
swfPath : '/res/js/plug/ZeroClipboard/ZeroClipboard.swf'
});
ZeroClipboard.create();
clip.on("copy", function(event) {
clip.setText($.trim($('#id_union_url_txt').text())); // 设置要复制的文本。
layer.alert("复制推广链接成功!");
});