Javascript examples for DOM HTML Element:Option
get a selected option's value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function getValue() {//from w w w.j a v a 2 s . c om var val = document.getElementById("test").value; console.log(val); } </script> </head> <body> <select id="test"> <option value="1">first</option> <option value="2">second</option> </select> <input type="button" onclick="getValue();" value="get value"> </body> </html>