复制

 ---------------------------------------------------------------------------------原----------------------------------------------------------------------
<!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>

 

posted @ 2019-12-05 09:28  起啥名嘞  阅读(150)  评论(0编辑  收藏  举报