<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQ复制内容文本</title>
</head>
<body>
<button data-clipboard-text="a1111">copy</button><br />
<button data-clipboard-text="b1111">copy</button><br />
<button data-clipboard-text="c1111">copy</button>
<script src="https://cdn.bootcdn.net/ajax/libs/clipboard.js/1.5.5/clipboard.min.js"></script>
<script type="text/javascript">
var btns = document.querySelectorAll('button');
var clipboard = new Clipboard(btns);
clipboard.on('success', function(e) {
console.log(e);});
clipboard.on('error', function(e) {
console.log(e);});
</script>
</body>
</html> |