The DOM Input select() method selects all the text content of a textarea or an input element which contains the text field.
Syntax:
element.select();
Parameters: This method does not accepts any parameters.
Example: This example selects the content of input text field.
<!DOCTYPE html> <html> <head> <title>HTML DOM focus() Method</title> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOM select() Method</h2> <input type="text" id="text-box" size="20" value="A computer science portal"> <button onclick="selectText()"> Select text </button> <script> function selectText() { const content = document.getElementById('text-box'); content.select(); } </script> </center> </body> </html> |
chevron_right
filter_none
Output:
- Before Clicking the button:

- After Clicking the button:

Supported Browsers: The browsers supported by HTML DOM Input Text select() Method are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- How to select all text in HTML text input when clicked using JavaScript?
- HTML | DOM Input Password select() Method
- How to select text input fields using CSS selector ?
- How to Select Multiple Files using HTML Input Tag ?
- HTML | DOM Input Text name Property
- HTML | <input type="text">
- HTML | DOM Input Text Object
- HTML | DOM Input Text value Property
- HTML | DOM Input Text defaultValue Property
- HTML | DOM Input Text minLength Property
- HTML | DOM Input Text autocomplete Property
- HTML | DOM Input Text autofocus Property
- HTML | DOM Input Text disabled Property
- HTML | DOM Input Text form Property
- HTML | DOM Input Text maxLength Property
- HTML | DOM Input Text required Property
- HTML | DOM Input Text size Property
- HTML | DOM Input Text pattern Property
- HTML | DOM Input Text readOnly Property
- HTML | DOM Input Text placeholder Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


