Change the selected option in a drop-down list to "orange":
The selected property sets or returns the selected state of an option.
The selected property is supported in all major browsers.
Return the selected property:
Set the selected property:
Value | Description |
---|---|
true|false |
Specifies whether an option in a drop-down list should be selected
or not.
|
Return Value: | A Boolean, returns true if the option is selected, otherwise it returns false |
---|
Find out if the "banana" option in a drop-down list is selected or not:
HTML reference: HTML <option> selected attribute