EDIT This question is NOT a dupe of Setting "checked" for a checkbox with jQuery? because this question here specifically asks about the special case where: "Once a user clicks on a checkbox, that checkbox stops responding to the "checked" attribute changes.".
There's one answer (one with few upvotes compared to the other) that talks about that, but all the links in that answer are utterly broken...
I'm trying to do something "out of curiosity". There's no point in what I'm trying to do.
I successfully used JQuery to display if a checkbox just got checked or unchecked using an alert. The following works fine:
$(document).ready(function() {
$('.cb').change(function(){
if ($('.cb').is(':checked')) {
alert('changed to checked');
} else {
alert('changed to unchecked');
}
});
});
However I can't figure out how to turn back the checkbox to its initial state (once again: there's no point in doing that, but I want to do it).
Is it possible to do that and will is it possible to toggle back the checkbox to its original state without triggering the change event?
I tried attr and removeAttr to no avail.