상세 컨텐츠

본문 제목

[PHP] JQuery 버튼 누르면 select 비 활성화

php

by 2hansoul 2021. 11. 10. 20:00

본문

반응형
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script>
$(document).ready(function() {          
  $("input:radio[name=send]").click(function(){       //input타입은 radio로 설정 하고 name을 준다 클릭하면 실행
      if($("input:radio[name=send]:checked").val()=='1'){      //radio가 눌리고 input radio value 값과 일치 하면 실행
          $("#year").attr("disabled",false);                    // 비활성화 시키기 select disabled=true 로 설정 해놨음         
          //$("#year").removeClass("readonly");    //select 에 class를 지워 줘야 한다고 하는데 애초에 select class안 잡았                                                                 기때문에 필요없다고 생각함 
      } else if($("input:radio[name=send]:checked").val()=='2') {
          $("#year").attr("disabled",true);
         // $("#year").addClass("readonly");
      }
  });
});
</script>





<input type="radio" name="send" id="1" value="1" ><label >버튼1번</label>

<input type="radio" name="send" id="2" value="2" checked><label>버튼2번</label>

<select class="" id="year" name="year" disabled=true >
반응형

관련글 더보기

댓글 영역