<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea"> 342 Alvin Road Ducksburg</textarea> <p>Click the button to select the content of the text area.</p> <button type="button" onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("myTextarea").select(); } </script> </body> </html>
JS Textarea select() Method 代码全选输入框
16 min read