I understand that this question may get closed for being duplicate (sorry if it is), but in my particular case, there may be a different problem for the functionality not working as desired, then it was in other similar questions.
Suppose we have a markup:
<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>
And a JS attached in the document.ready event:
$(document).ready(function() {
$('#IsRecurring').click(function () {
var thisCheck = $(this);
if (thischeck.is(':checked'))
$('#schedulerTypesList').show();
}
else {
$('#schedulerTypesList').hide();
})
});
Why checkbox click event isn’t toggling the display of a div?
A few issues !!
Missing bracket after the
ifandthischeckinstead ofthisCheckand added correct closing brackets. Working demo : http://jsfiddle.net/manseuk/4DqXv/18/