HTML <optgroup> disabled egenskab

Definition og brug

disabled Egenskab er en boolsk egenskab.

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 Properties are 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 an automotive 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 property.

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