<script src="clipboard.js-master/dist/clipboard.min.js" type="text/javascript"></script>
<input id="foo" value="这里是内容123">
<button class="btn" data-clipboard-target="#foo">点击复制</button>
<script>
var clipboard = new Clipboard('.btn');
clipboard.on('success', function(e) {
alert("复制成功!");
e.clearSelection();
});
clipboard.on('error', function(e) {
alert("复制失败!");
});
</script>
clipboard 下载地址:https://pan.baidu.com/s/1c2EVJxe
来源:https://www.huoduan.com/clipboardjs.html
网友评论