Option defaultSelected Property

Definition and Usage

defaultSelected the property returns selected property the default value.

If the default selected option is returned, 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> 태그

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);

직접 시도해 보세요

문법

optionObject.defaultSelected

기술 세부 사항

반환 값: 부울 값, 기본 선택된 옵션을 선택하면 true를 반환하며, 그렇지 않으면 false를 반환합니다.

브라우저 지원

크롬 에지 파이어폭스 사파리 오페라
크롬 에지 파이어폭스 사파리 오페라
지원 지원 지원 지원 지원