HTML DOM 옵션 개체
옵션 개체
Option 객체는 HTML <option> 요소를 나타냅니다.
옵션 개체에 액세스
getElementById()를 사용하여 <option> 요소에 액세스할 수 있습니다.
예시
var x = document.getElementById("myOption");
팁: 양식의 요소 컬렉션이나 드롭다운 목록 의 옵션 컬렉션 을 검색하여 Option 개체에 액세스할 수도 있습니다 .
옵션 개체 만들기
document.createElement() 메서드를 사용하여 <option> 요소를 만들 수 있습니다.
예시
var x = document.createElement("OPTION");
옵션 개체 속성
Property | Description |
---|---|
defaultSelected | Returns the default value of the selected attribute |
disabled | Sets or returns whether an option is disabled, or not |
form | Returns a reference to the form that contains the option |
index | Sets or returns the index position of an option in a drop-down list |
label | Sets or returns the value of the label attribute of an option in a drop-down list |
selected | Sets or returns the selected state of an option |
text | Sets or returns the text of an option |
value | Sets or returns the value of an option to be sent to the server |
표준 속성 및 이벤트
Option 객체는 표준 속성 과 이벤트 도 지원합니다 .
관련 페이지
HTML 참조: HTML <option> 태그