HTML DOM Input Text focus() Method Last Updated : 31 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The Input Text focus() method in HTML DOM is used to get focus to the text field when the event occurs. Syntax: textObject.focus() Parameters: This method does not contain any parameter values. Return Value: It does not return any value. Example: Below program illustrates the use of the input text focus() method in HTML DOM. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM Input Text focus() Method </title> </head> <body style="text-align:center;"> <h1 style="color:green"> GeeksforGeeks </h1> <strong>DOM Input Text focus() method</strong> <form id="myForm"> <input type="text" id="text_id" name="userinput"> </form> <br> <button onclick="myfocus()">Get Focus!</button> <!-- script to get focus to the text field--> <script> function myfocus() { var txt = document.getElementById("text_id").focus(); } </script> </body> </html> Output: HTML DOM Input Text focus() Method Supported Browsers: Google Chrome 1Mozilla Firefox 1Edge 12OperaSafari 1 Comment More infoAdvertise with us Next Article HTML DOM Input Text focus() Method M manaschhabra2 Follow Improve Article Tags : HTML HTML-DOM HTML-Methods Similar Reads HTML DOM Input Tel focus() Method The input tel focus() method in HTML DOM is used to get focus to an input tel field when the event occurs. Syntax: telObject.focus() Parameters: This method does not accept any parameter values. Return Value: This method does not return any values. Example: Below HTML code illustrates the use of the 1 min read HTML DOM Input URL focus() Method The Input URL focus() method in HTML DOM is used to get focus to the Input URL field when the event occurs. We can use this method for directing the focus of the user when an event occurs. Syntax: URLObject.focus() Parameters: This method does not contain any parameter values. Return Value: It does 1 min read HTML DOM Input Search focus() Method The Input Search focus() Method in HTML DOM is used to get focus to the Input search Field when an event occurs. Syntax: searchObject.focus();Parameter: This method does not contain any parameter value. Return Value: It does not return any value. Example: The below example illustrates the use of the 1 min read HTML DOM Input Text blur() Method The Input Text blur() method in HTML DOM is used to pull or remove focus from the text field when the event occurs. Syntax: textObject.blur() Parameters: This method does not contain any parameter values. Return Value: It does not return any value. Example: Below program illustrates the use of the i 1 min read 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> 1 min read Like