应用一:
<div class="dobest font14" id="dobest" style="padding: 0rem 0.2rem 0.2rem;" data-clipboard-action="copy" onClick="copy()">
</div>
<script type="text/javascript">
var clipboard = new Clipboard('.dobest', {
text: function(trigger) {
return $('#dobest').html();
}
});
function copy(){
layer.msg('复制成功!');
}
$.post('./result.php',{action:'read', categoryid:20}, function(json){
var data = json.data;
$('#dobest').html(data['content']);
}, 'json')
</script>
应用二:
nhtml += '<input class="invitecode" name="invitecode" type="text" value="'+ v.code +'" readonly="true" data-clipboard-text=" 第'+ i +'条【点击链接开通年会员】http://www.xxxx.com/xxxx/xxxx.php?uid='+ agentid + '&invitecode='+ v.code + '&url=agent/vip" data-clipboard-action="copy" onClick="copy(\'第'+ i +'条\')" />';
var clipboard = new Clipboard('.invitecode');
function copy(val){
layer.msg(val+'复制链接地址成功!');
}