HTML DOM Input Tel focus() Method
Last Updated :
05 May, 2022
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;" >
GeeksforGeeks
</ 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
Share your thoughts in the comments
Please Login to comment...