HTML <optgroup> disabled eigenschap

Definitie en gebruik

disabled Eigenschap is een booleaanse eigenschap.

When present, it specifies that the option group should be disabled.

Disabled option groups are not available and cannot be clicked.

Can be set disabled The attribute is set to prevent the user from selecting the option group until certain other conditions are met (such as checking a checkbox, etc.). Then, JavaScript needs to be used to remove the disabled value, making the option group selectable.

Example

Disabled option group:

<label for="cars">Please select a car brand:</label>
<select name="cars" id="cars">
  <optgroup label="German cars" disabled>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>

Try it yourself

Syntax

<optgroup disabled>

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 8.0 Support Support Support