The input Tel list property in HTML DOM is used to return a reference to the list element that contains an input tel field.
Syntax:
telObject.list.id
Return value: It returns a string value that represents the value of the id attribute of the datalist element.
Example: Below HTML code used to return the input tel list property.
HTML
<!DOCTYPE html> < html >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 > DOM Input Tel list property </ h2 >
< legend >
Phone Number:
< input type = "tel" id = "mytel" list = "telephone_list" value = "6753682635" autofocus>
</ legend >
< datalist id = "telephone_list" >
< option value = "87688965" />
< option value = "998347589" />
< option value = "99384339" />
< option value = "837494493" />
< option value = "8474748437" />
</ datalist >< br >< br >
< button onclick = "btnclick()" >
Click Here!
</ button >
< p id = "paraID" style = "font-size:20px" ></ p >
< script >
function btnclick() {
var x = document.getElementById("mytel").list.id;
document.getElementById("paraID").innerHTML = x;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome
- Edge
- Mozilla Firefox
- Opera
- Safari