Textarea select() 方法
Textarea 對(duì)象定義和用法
select() 方法用于選擇該元素中的文本。
語法
textareaObject.select()
瀏覽器支持
所有主流瀏覽器都支持 select() 方法
實(shí)例
實(shí)例
下面的例子可選擇文本框中的文本:
<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 對(duì)象
更多建議: