I need to trigger some code when I click a checkbox based on if a checkbox is checked or not. But for some reason, .is(':checked') is always triggered.
This is my code.
jQuery('#selectlist input[type=checkbox]').live('click',function(){ var select_id = jQuery(this).attr('id'); if(jQuery(this).is(':checked')) { alert('You have unchecked the checkbox'); // Remove some data from variable } else { alert('You have checked the checkbox'); //Add data to variable } } UPDATE
I've added an example on JSFiddle: http://jsfiddle.net/HgQUS/