一、下载
https://github.com/zenorocha/clipboard.js/archive/master.zip
二、Demo示例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <input id="foo" type="text" value="hello"> <button class="btn" data-clipboard-action="copy" data-clipboard-target="#foo">Copy</button> <script src="./clipboard/clipboard.js"></script> <script> var clipboard = new Clipboard('.btn'); clipboard.on('success', function (e) { console.log(e); }); clipboard.on('error', function (e) { console.log(e); }); </script> </body> </html>
三、第三方Demo地址
http://www.webkaka.com/Blog/ARCHIVES/demo/clipboard.js-master/demo/index.html