Option defaultSelected Property

Definition and Usage

defaultSelected the 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 if 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);

Try It Yourself

Syntax

optionObject.defaultSelected

Technical Details

Return Value: Boolean value, returns true if the option is selected by default; otherwise returns false.

Browser Support

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