Javascript examples for DOM HTML Element:OptionGroup
The label property sets or gets the label attribute of an option-group, which is the label/description for an option-group.
Set the label property with the following Values
Value | Description |
---|---|
text | Sets a label/description for the option-group |
A String, representing the label of the option-group
The following code shows how to change the label/description of an option-group:
<!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>/*www. j a va 2s .c o m*/ <button onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myOptgroup").label = "Selection"; } </script> </body> </html>