Javascript examples for DOM HTML Element:Datalist
The Datalist object represents an HTML <datalist> element.
You can access a <datalist> element by using getElementById():
<!DOCTYPE html> <html> <body> <form> <input list="myDatalist"> <datalist id="myDatalist"> <option value="Internet Explorer"> <option value="Firefox"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist> </form>/* w w w .j a v a 2s .com*/ <button onclick="myFunction()">get the number of option elements in the datalist</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myDatalist").options.length; document.getElementById("demo").innerHTML = "Found " + x + " options in the list."; } </script> </body> </html>