HTML DOM Input Text select() Method
The DOM Input select() method selects all the text content of a textarea or an input element that contains the text field.
Syntax:
element.select();
Parameters: This method does not accept any parameters.
Example: This example selects the content of the input text field.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM Input Text select() Method </ title > </ head > < body > < h1 style = "color:green;" > w3wiki </ 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 > </ body > </ html > |
Output:
Supported Browsers: The browsers supported by HTML DOM Input Text select() Method are listed below:
- Google Chrome 1
- Edge 12
- Firefox 1
- Apple Safari 1
- Opera
Contact Us