Search w3schools.com:

SHARE THIS PAGE

Text select() Method

Text Object Reference Text Object

Definition and Usage

The select() method is used to select the content of a text field.

Syntax

textObject.select()


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

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 Reference Text Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]