运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>Use select() to select the content of a Search Field</h2> Search: <input type="search" id="mySearch"> <p>Write something in the search field above, then click the button to select the content of the search field.</p> <button type="button" onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("mySearch").select(); } </script> </body> </html>