Textarea select() 方法

定義和用法
select() 方法用於選擇該元素中的文本。
語法
textareaObject.select()
流覽器支持
所有主流流覽器都支持 select() 方法
實例
實例
下麵的例子可選擇文本框中的文本:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在IT研修,你可以學多很多編程的基礎知識,包括 HTML, XML, SQL, ASP, 和 PHP 等各種前端內容。
</textarea>
<br>
<button type="button" onclick="displayResult()">選擇文本框中的文本</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult()
{
document.getElementById("myTextarea").select();
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在IT研修,你可以學多很多編程的基礎知識,包括 HTML, XML, SQL, ASP, 和 PHP 等各種前端內容。
</textarea>
<br>
<button type="button" onclick="displayResult()">選擇文本框中的文本</button>
</body>
</html>
