다중 select

by 조쉬 posted Mar 31, 2021
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
body>
    <select id="first">
        <option value="">선택</option>
        <option value="a">a</option>
        <option value="b">b</option>
    </select>
    <select id="second" disabled>
        <option value="">선택</option>
        <option value="1">1</option>
        <option value="2">2</option>
    </select>
    <select id="third" disabled>
        <option value="">선택</option>
        <option value="ㄱ"></option>
        <option value="ㄴ"></option>
    </select>
</body>
<script>
$("#first").change(function(){
    if(this.value!=""){
        $("#second").removeAttr("disabled");
    }else{
        $("#second").attr("disabled", "disabled");
        $("#third").attr("disabled", "disabled");
    }
});
$("#second").change(function(){
    if(this.value!=""){
        $("#third").removeAttr("disabled");
    }else{
        $("#third").attr("disabled", "disabled");
    }
});
</script>