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 input tel focus() method. 

HTML




<!DOCTYPE html>
<html>
  
<body style="text-align:center;">
    <h1 style="color:green;">
        w3wiki
    </h1>
  
    <h2> DOM Input Tel focus() method </h2>
      
    <legend>
        Phone Number:
        <input type="tel" id="mytel" value="6753682635">
    </legend>
    <br><br>
      
    <button onclick="btnclick()">
        Click Here!
    </button>
      
    <script>
        function btnclick() {
            var x = document.getElementById("mytel").focus();
        }
    </script>
</body>
  
</html>


Output: 

           

 

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera