Javascript examples for DOM HTML Element:Select
Select options Collection [index] - Get the text of the first option (index 0) in a drop-down list:
<!DOCTYPE html> <html> <body> <form> <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select> </form>/*w w w.j a v a2 s. com*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySelect").options[0].text; document.getElementById("demo").innerHTML = x; } </script> </body> </html>