This is my checkbox, which should be checked by default
<input type="checkbox" name="noILN-GLN" id="noILN-GLN" checked="checked" />
I now want an event to fire when the checkbox changes and then do this (checked) or that (not checked). This is always returns “checked”:
$('#noILN-GLN').bind('change', function() {
if ( $(this).attr('checked') ) {
console.log("checked")
} else {
console.log("not checked");
}
});
What do I have to change to make the console tell me if the box is checked or not? It needs to be checked by default, so I’m setting checked=”checked”. Any other way to pre-check the box, that might help?
Thanks!
Try this