Reputation: 5438
I have two checkbox change events as follows:
1) This targets a specific checkbox:
$('#category').on('change', '#cars input[type=checkbox]', function(){
//
});
2) And this targets all checkboxes:
$('#category').on('change', 'input[type=checkbox]', function(){
//
});
The second event seems to be firing before the first one, but I would like the opposite instead.
How can I specify the order?
Upvotes: 3
Views: 56
Reputation: 6120
If applicable, you should try something like this instead:
$('#category').on('change', 'input[type=checkbox]', function(){
if ($(this).parent().attr('id')=='cars') {
//do for cars
}
//do for everything
});
Upvotes: 4