Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Last active February 23, 2016 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanbrujo/15e3648b34a6e679bac3 to your computer and use it in GitHub Desktop.
Save juanbrujo/15e3648b34a6e679bac3 to your computer and use it in GitHub Desktop.
jQuery checkboxes attach event on change state
// react then checkbox change state
$('input[type="checkbox"]').on('change', function(e) {
if( this.checked ) {
console.log('checked');
} else {
console.log('not checked');
}
});
// check
$('input[type="checkbox"]').prop('checked', true);
// uncheck
$('input[type="checkbox"]').prop('checked', false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment