The input URL list property in HTML DOM is used to return a reference to the datalist element that contains an input URL field.
Syntax:
urlObject.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 is used to return the input URL list property.
HTML
<!DOCTYPE html> < html >
< head >
< title >DOM Input URL list Property</ title >
</ head >
< body >
< center >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >DOM Input URL list Property </ h2 >
< label for = "uname" style = "color:green" >
< b >Enter URL</ b >
</ label >
< input type = "url" id = "inputID" list = "url_list"
placeholder = "Enter URL" >
< datalist id = "url_list" >
< option value = "Google.com" />
< option value = "amazon.com" />
< option value = "flipkart.com" />
< option value = "Twitter.com" />
< option value = "Facebook.com" />
</ datalist >< br >
< br >< br >
< button type = "button" onclick = "btnclick()" >
Click Here!
</ button >
< p id = "paraID" style = "color:green;font-size:20px;" > </ p >
< script >
function btnclick() {
// Return the Input URL list property.
var link = document.getElementById("inputID").list.id;
document.getElementById("paraID").innerHTML = link;
}
</ script >
</ center >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome 1
- Edge 12
- Mozilla Firefox
- Opera 11
- Safari