<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> <textarea name="" id="txt" >内容</textarea> <input type="button" onclick="fu()" value="点击复制"></input> <script> let txt = document.getElementById('txt'); function fu(){ txt.select(); document.execCommand('copy'); alert("内容复制成功!!!"); } </script> </body> </html>