Javascript examples for DOM HTML Element:Option
Option label Property - Alert the label value of the selected option in a drop-down list:
<!DOCTYPE html> <html> <body> Select your favorite car: <br> <select id="mySelect" size="4"> <option label="c">cc</option> <option id="myOption" label="d">dd</option> </select>//from w w w .j a v a 2 s .c o m <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() { var x = document.getElementById("mySelect").selectedIndex; console.log(document.getElementsByTagName("option")[x].label); } </script> </body> </html>