TIL

TIL - 20220907

Lee Jaeyoon2 2022. 9. 7. 23:00

 오늘은 모던 JavaScript 튜토리얼에서 폼 프로퍼티와 메서드에 대해 공부했다. 작성한 질문은 다음과 같다.

 <select> 요소에는 세 가지 중요 프로퍼티가 있다.

  • select.options: <options> 하위 요소를 담고 있는 컬렉션
  • select.value: 현재 선택된 <option> 값
  • select.selectedIndex: 현재 선택된 <option>의 인덱스

 

 Function, Event 생성자 함수로 Option도 만들 수 있다.

option = new Option(text, value, defaultSelected, selected);
  • text: option 내부의 텍스트
  • value: option의 값
  • selected: true면 해당 값이 선택된다.
  • defaultSelected: true면 HTML 속성 selected가 생성된다.