Heojju

[jQuery] 다중 select 본문

웹개발/jQuery

[jQuery] 다중 select

우주별 2017. 2. 9. 11:47
<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>