How to listen to when a checkbox is checked in Jquery

Viewed 102364

I need to know when any checkbox on the page is checked:

e.g.

<input type="checkbox">

I tried this in Jquery

$('input type=["checkbox"]').change(function(){
alert('changed');
});

But it didn't work, any ideas?

7 Answers

If you want to use .on this works

 jQuery('input[type=checkbox]').on('change', function() {
   if (this.checked) {
     console.log('checked');
   }
 });
Related