Textarea select() 方法
Textarea 对象定义和用法
select() 方法用于选择该元素中的文本。
语法
textareaObject.select()
浏览器支持
所有主流浏览器都支持 select() 方法
实例
实例
下面的例子可选择文本框中的文本:
<html>
<head>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
At W3Cschools you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
<br>
<button type="button" onclick="displayResult()">Select contents of text area</button>
</body>
</html>
<head>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
At W3Cschools you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
<br>
<button type="button" onclick="displayResult()">Select contents of text area</button>
</body>
</html>
Textarea 对象
更多建议: