I think the problem comes from here: $('#CheckBox' + id).attr("checked") == true . According to the HTML specifications, checked must be set to "checked" when this event fires. So, try using something like $('#CheckBox' + id).attr("checked") == "checked" or even $('#CheckBox' + id).attr("checked") .
As a second option, I recommend using pure jquery to run your program. For example, if you have a flag <input type="checkbox" id="ac"> , you can use this jq code to process your routines:
$(document).ready(function() { $("input[type=checkbox]").change(function() { alert("Am i checked? - " + $(this).attr("checked") + "\nMy ID:" + $(this).attr("id")); }); });
This case is shown in this demo .
shybovycha
source share