At the end of the code you posted, there are a few closing brackets missing, I'm not sure if you just didn't copy / paste all of this or missed or broken your code:
This is what you posted (after entering the indentation):
if (isChildAvail == "true") { $(this).change(function () { if ($(this).is(':checked')) { alert("test"); $(this).parent().parent().append('<div id="divedit" class="editdiv"><p id="p_childlabel" class="childlabel">Children : ' + ChilAvailCount + ' </P><a class="childlabeledit">Edit</a></div>'); $('.editdiv a').click(function () { $(this).parent().parent().append($("#divchildcontrol")); EditForPullups(); }); } }
Missing end of change event handler ); , as well as closing closed for if } block:
if (isChildAvail == "true") { $(this).change(function () { if ($(this).is(':checked')) { alert("test"); $(this).parent().parent().append('<div id="divedit" class="editdiv"><p id="p_childlabel" class="childlabel">Children : ' + ChilAvailCount + ' </P><a class="childlabeledit">Edit</a></div>'); $('.editdiv a').click(function () { $(this).parent().parent().append($("#divchildcontrol")); EditForPullups(); }); } }); }
This (simplified) example works fine for me in IE9: http://jsfiddle.net/rT2dT/1/
$(':checkbox').change(function () { if ($(this).is(':checked')) { alert("test"); } });
Alternatively try
$(':checkbox').change(function () { if ($(this).prop('checked') === true) { alert("test"); } });
What version of jQuery are you using?
EDIT: Following your 2nd right from above:
I see that you attach event handlers in each loop
$('.consumer-communication-checkbox').each(function () {
I assume that this selector will be on different checkboxes on your page. Inside this each look, you attach change handlers like this:
$(':checkbox').change(...
This selector will provide you with all the checkboxes on the entire page, and not just one in the area. In each iteration of each loop, you attach one of these event handlers to each flag on the page. Without knowing your HTML markup, I cannot tell you exactly what is happening, but this will cause everything to work as expected in isolated examples (like JSFiddle.net) and return random results in context.