채택완료

click 이벤트 추가 질문 드려요

2017-08-29 (화) 18:04:56 2,123

<input type="checkbox" name="" id="chk"> 를 체크 하기 전에는

폼안에 input / select / textarea 게 disabled 상태이고


<input type="checkbox" name="" id="chk"> 체크하면 

입력이나 선택 가능하게 할려면 어떻게 해야 될까요~ ?

<form name="fwrite">

...

</form>

|

답변 2개 / 댓글 1개

채택된 답변
+20 포인트

Copy
<input id="id1" value=""  onclick="ableThis()" disable><script>function ableThis(){ $("#id1").removeAttr( "disable" );  $("#id1").focus(); }</script>
 

답변에 대한 댓글 1개

질문의 전달이 좀 잘못되었네요.

폼 밖에 <input type="checkbox" name="" id="chk"> "입력가능" 이란 체크박스를 클릭시

폼 안에 input / select / textarea 가 일괄적으로 disabled & 해제 가 되었으면 하는 거거든요

var forms = $('[name=fwrite]').find('input, select, textarea').prop('disabled', true);

$('#chk').on('change', function() {

  if (this.checked) {

    forms.prop('disabled', false);

  } else {

    forms.prop('disabled', true);

  }

});

답변을 작성하려면 로그인이 필요합니다.