The select()
method selects the entire contents of a textarea.
select |
Yes | Yes | Yes | Yes | Yes |
textareaObject.select()
None.
No return value.
The following code shows how to select the contents of a textarea.
<!DOCTYPE html>
<html>
<body>
Address:<br>
<textarea id="myTextarea">
this is a test<!--from w w w . j ava 2 s .c o m-->
</textarea>
<button type="button" onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myTextarea").select();
}
</script>
</body>
</html>
The code above is rendered as follows: