自强学堂
自强学堂:学习、分享、让你更强!
JavaScript 参考手册HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

HTML DOM Textarea select() 方法

Textarea 对象参考手册 Textarea 对象

定义和用法

select() 方法用于选择该元素中的文本。

语法

textareaObject.select()


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持 select() 方法


实例

实例

下面的例子可选择文本框中的文本:

<html>
<head>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>

<textarea id="myTextarea" cols="20">
At ZiQiangXueTang 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 对象参考手册 Textarea 对象