Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <h3>A demonstration of how to access a DATALIST element</h3> <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> <p>Click the button to get the number of option elements in the datalist.</p> <button onclick="myFunction()">Try it</button> <p><strong>Note:</strong> The input element's list attribute is used to bind it together with the datalist element.</p> <p><strong>Note:</strong> The datalist element is not supported in Internet Explorer 9 and earlier versions, or in Safari.</p> <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> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_datalist_get by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:01:10 GMT --> </html>
Result:
Try it Yourself - © w3schools.com