jQuery
jQuery select 셀렉트 박스 선택값 지정
은둔한량
2023. 9. 1. 09:16
반응형
jquey 는 맨날 까먹는다.
그래서 간단한것은 정리를 해서 다음부터 쉽게 사용하자
//select box의 내용 가져오기
$("#select_box > option:selected").val();
//select box의 값 설정
$("#select_box > option[value=지정값]").attr("selected", "true")
//select disabled
$('#select_box').attr('disabled', 'true');
// 해제
$('#select_box').attr('disabled', ''); // 'false'를 줬을 경우 안됨
//select box의 내용 가져오기
var value = $("#select_box > option:selected").val();
//select box의 값 설정
$("#select_box > option[value=지정값]").attr("selected", "true")
//select disabled
$('#select_box').attr('disabled', 'true');
// 해제
$('#select_box').attr('disabled', ''); // 'false'를 줬을 경우 안됨
반응형