HTML DOM select() 方法
定义和用法
select() 方法用于选取文本域中的内容。
语法
- textObject.select()
实例
下面的例子可选取文本域中的内容:
- <html>
- <head>
- <script type="text/javascript">
- function selText()
- {
document.getElementById("myText").select()
- }
- </script>
- </head>
- <body>
- <form>
- <input size="25" type="text" id="myText" value="A cat played with a ball">
- <input type="button" value="Select text" onclick="selText()">
- </form>
- </body>
- </html>