---------------------------------------------------------------------------------原----------------------------------------------------------------------
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <textarea id="copy">acret</textarea> <input type="button" οnclick="copy();" value="点击复制"></input> </body> <script type="text/javascript"> function copy() { console.log('aaa') var e = document.getElementById("copy"); e.select(); // 选择对象 document.execCommand("Copy"); // 执行浏览器复制命令 alert("复制成功!"); } </script> </html>