2012-01-27 1 views
0

이 질문은 중복되는 경우 미안하지만 (미안, 필자의 경우) 원하는대로 작동하지 않는 다른 문제가있을 수 있음을 이해합니다. 다른 비슷한 질문을했다.체크 박스 클릭 이벤트 처리를 위해 jQuery 가져 오기

$(document).ready(function() { 
    $('#IsRecurring').click(function() {   
     var thisCheck = $(this); 
     if (thischeck.is(':checked')) 
      $('#schedulerTypesList').show(); 
     } 
     else { 
      $('#schedulerTypesList').hide(); 
     }) 
    }); 

Demo in JSFiddle.

왜 체크 박스를 클릭 이벤트가 화면을 전환하지 않는 다음 document.ready 이벤트에 부착

<div> 
    <label for="IsRecurring">Is Recurring</label> 
</div> 
<div> 
    <input id="IsRecurring" name="IsRecurring" type="checkbox" value="true"> 
    <input name="IsRecurring" type="hidden" value="false" />    
</div> 

<div id="schedulerTypesList" style="display:none"> 
    <div> 
     <label for="ScheduleTypeId">Schedule</label> 
    </div> 
    <div class="editor-field"> 
     <input type="hidden" name="ScheduleTypeId" id="ScheduleTypeId" value="" /> 

     <ul id="ScheduleTypeIdlist" > 
      <li>Once a weel</li> 
     </ul> 
    </div> 
</div> 

그리고 JS : 가정하자

우리는 마크 업을 한 div의?

답변

3

몇 가지 문제 !!

$(document).ready(function() { 
    $('#IsRecurring').click(function() { 
     var thisCheck = $(this); 
     if (thisCheck.is(':checked')) { // added this closing bracket 
      $('#schedulerTypesList').show(); 
     } 
     else { 
      $('#schedulerTypesList').hide(); 
     } // added this closing bracket 
    }); 
}); 

누락 브래킷 ifthischeck 대신 thisCheck 후 정확한 폐쇄 브래킷을 추가했다. 실무 데모 : http://jsfiddle.net/manseuk/4DqXv/18/

+0

멍청한 데요.) 감사합니다. –

+0

@ MaximV.Pavlov 우리 모두 거기에있다 .... :-) – ManseUK