<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>constructor-node</title>
</head>
<!-- 1. Define some markup -->
<div id="btn" data-clipboard-text="1">
<span>Copy</span>
</div>
<a href="" aria-label="sjdkf" class="btn-copy" id="aaaaaaaa">复制</href>
<!-- 2. Include library -->
<script src="clipboard.min.js"></script>
<!-- 3. Instantiate clipboard by passing a HTML element -->
<script>
var clipboard = new Clipboard('.btn-copy', {
text: function (trigger) {
return trigger.getAttribute('aria-label');
}
});
clipboard.on('success', function (e) {
console.log(e);
});
clipboard.on('error', function (e) {
console.log(e);
});
</script>
</body>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>constructor-node</title>
</head>
<!-- 1. Define some markup -->
<div id="btn" data-clipboard-text="1">
<span>Copy</span>
</div>
<a href="" aria-label="sjdkf" class="btn-copy" id="aaaaaaaa">复制</href>
<!-- 2. Include library -->
<script src="clipboard.min.js"></script>
<!-- 3. Instantiate clipboard by passing a HTML element -->
<script>
var clipboard = new Clipboard('.btn-copy', {
text: function (trigger) {
return trigger.getAttribute('aria-label');
}
});
clipboard.on('success', function (e) {
console.log(e);
});
clipboard.on('error', function (e) {
console.log(e);
});
</script>
</body>
</html>
资源下载地址:压缩包(js+html)
http://download.csdn.net/detail/qing_mei_xiu/9920573