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?

MAX POWER
  • 5,213
  • 15
  • 89
  • 141
  • possible duplicate of [How to order events bound with jQuery](http://stackoverflow.com/questions/290254/how-to-order-events-bound-with-jquery) – musefan Feb 28 '14 at 12:35

1 Answers1

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
});
dkasipovic
  • 5,930
  • 1
  • 19
  • 25