Option label Property - Return the label value of an option in a drop-down list: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Option

Description

Option label Property - Return the label value of an option in a drop-down list:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select>
  <option label="c">cc</option>
  <option id="myOption" label="d">dd</option>
</select>/*  ww w.  j a  va2  s  . c o  m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var v = document.getElementById("myOption").label;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials