optgroup - Return the label/description of an option-group: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:OptionGroup

Description

optgroup - Return the label/description of an option-group:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select size="6">
  <option value="B">B</option>
  <option value="M">M</option>
  <optgroup id="myOptgroup" label="Swedish Cars">
    <option value="css">CSS</option>
    <option value="html">HTML</option>
    <option value="sql">SQL</option>
  </optgroup>
</select>/* ww w.ja  v  a 2 s.  c om*/

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

<script>
function myFunction() {
    document.getElementById("myOptgroup").label = "selection";
}
</script>

</body>
</html>

Related Tutorials