HTML <option> disabled eigenschap
Definitie en gebruik
disabled
Eigenschap is een booleaanse eigenschap.
Wanneer aanwezig, bepaalt het dat de opties moeten worden gedeactiveerd.
De gedeactiveerde opties zijn niet beschikbaar en klikbaar.
Can be set disabled
Properties are set to prevent the user from selecting this option until certain other conditions are met (such as checking a checkbox, etc.). Then, a JavaScript is needed to remove the disabled value, making the option selectable.
Example
A dropdown list with a disabled option:
<label for="cars">Please select a car brand:</label> <select id="cars"> <option value="audi" disabled>Audi</option> <option value="byd">BYD</option> <option value="geely">Geely</option> <option value="volvo">Volvo</option> </select>
Syntax
<option disabled>
Browser support
The numbers in the table indicate the first browser version to fully support this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 8.0 | Support | Support | Support |