3

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?

1

1 Answer 1

4

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
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.