Text select() Method
Text Object
Definition and Usage
The select() method is used to select the content of a text field.
Syntax
Browser Support

The select() method is supported in all major browsers.
Example
Example
Select the content of a text field:
<html>
<head>
<script>
function myFunction()
{
document.getElementById("email").select();
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email" value="someone@example.com">
</form>
<button type="button" onclick="myFunction()">Select content</button>
</body>
</html>
Try it yourself »
Text Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]