1.添加dom
<span id="fu_container"><a href="javascript:;" id="fu_btn">點擊複製推廣地址</a></span>
<input type="hidden" value="<?php echo $activity->act_url;?>" id="fu_text" />
2.js
if($("#fu_text").length>0){
var clip = null;
clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
clip.addEventListener('mouseOver', function (client) {
clip.setText($("#fu_text").val());
});
clip.addEventListener('complete', function (client, text) {
$("#fu_success").fadeIn(1000,function(){
$(this).fadeOut(6000);
});
});
clip.glue('fu_btn','fu_container');
}
教程:https://github.com/zeroclipboard/ZeroClipboard