Javascript examples for DOM HTML Element:Datalist
Datalist options Collection [index] - Get the value of the first option (index 0) in a datalist:
<!DOCTYPE html> <html> <body> <form> <input list="browsers" name="browser"> <datalist id="browsers"> <option value="A"> <option value="B"> <option value="C"> <option value="D"> <option value="E"> </datalist> </form>// www .java2 s .c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("browsers").options[0].value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>