Javascript examples for DOM HTML Element:Select
Select options Collection item(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>//from ww w .j a v a 2 s. co m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySelect").options.item(0).text; document.getElementById("demo").innerHTML = x; } </script> </body> </html>