mardi 20 octobre 2015

jQuery - detecting when checkbox has changed

I have a range of checkboxes on my page and they will be dynamically checked/unchecked based on other dropdown options.

I can do this with

$('#first').prop('checked', true);

But i always need to detect whenever these change. I have tried:

jQuery(':checkbox').on('change', function() {
    alert('checkbox has changed');
});

Which works when i manually check/uncheck the boxes but not when they are dynamically set. How can this be done?

Example can be seen here:

jsfiddle




Aucun commentaire:

Enregistrer un commentaire