[jQuery] selecbox option값 자동 체크
- 📕 Programing/jQuery
- 2020. 5. 25. 17:09
jQuery를 활용해 특정값의 option값이 selected 되도록 하는 방법
$("#select_id").on("change", function(){
// 값이 1인 option 선택
$(this).val("1").prop("selected", true);
// OR option 순서값으로 선택
// 첫번째 option 선택
$(this).find("option:eq(0)").prop("selected", true);
});
// value 값으로 선택
$("#select_id").val("1").prop("selected", true);
// OR option 순서값으로 선택
$("#select_id option:eq(0)").prop("selected", true);
'📕 Programing > jQuery' 카테고리의 다른 글
[jQuery] 해당 요소의 상위요소 탐색 (0) | 2021.10.13 |
---|---|
[jQuery] 테이블의 선택한 열 값 가져오는 방법 (0) | 2021.08.24 |
$.ajax 을 활용한 JSON 파싱 (0) | 2020.05.13 |
[jQuery] $.getJSON 으로 JSON 출력하기 (0) | 2020.05.12 |
[jQuery] Document.ready , onload 실행 순서 (0) | 2020.05.11 |