Javascript examples for DOM HTML Element:Option
Option text Property - Return the text of the selected option in a drop-down list:
<!DOCTYPE html> <html> <body> Select your favorite fruit: <select> <option id="a">Apple</option> <option id="orange">Orange</option> <option id="pineapple">Pineapple</option> <option id="banana">Banana</option> </select>/*from w ww . ja v a 2 s . c o m*/ <button onclick="myFunction()">Test</button> <script> function myFunction() { var v = document.getElementById("a").text; console.log(v); } </script> </body> </html>