Latest web development tutorials

HTML DOM Textarea select () method

Textarea Object Reference Textarea object

Definition and Usage

select () method is used to select the text in the element.

grammar

textareaObject.select()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support select () method


Examples

Examples

The following examples can select text in a text box:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
    document.getElementById("myTextarea").select();
}
</script>
</head>
<body>

<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>

<button type="button" onclick="displayResult()">选择文本框中的文本</button>

</body>
</html>



Textarea Object Reference Textarea object