Option defaultSelected Property
Definition and Usage
defaultSelected
property returns selected property the default value.
If the default selected option is selected, this property returns true
, otherwise return false
.
Note:If an option is selected by default, it is displayed first in the drop-down list.
See also:
HTML Reference Manual:HTML <option> tag
Example
Check whether the selected option is selected by default:
var x = document.getElementById("mySelect").selectedIndex; var y = document.getElementsByTagName("option"); alert("Is " + y[x].text + " selected by default? " + y[x].defaultSelected);
Syntax
optionObject.defaultSelected
Technical details
Return value: | Boolean value, if the option is selected by default, it returns true; otherwise, it returns false. |
---|
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |