0

I have 2 $('.test).click function, with same name, how do I choose which to be triggered 1st?

  • this $('.test).click(function () {}) are located in 2 different .js file, however it will be combine when in the webpage
  • I'm not suppose to touch the 1st .js as it's come out of box with piwik, hence the reason I use $('.test).click(function () {}) on another js

So is there a way to decide which $('.test).click(function () {}) get triggered 1st?

Thanks

nicker
  • 477
  • 2
  • 6
  • 20
  • instead of having class selectors Use id selectors to differentiate. eg: $('#test1).click(function () {}), $('#test2).click(function () {}) – sameer Aug 10 '16 at 07:44
  • Possible duplicate of [How to order events bound with jQuery](http://stackoverflow.com/questions/290254/how-to-order-events-bound-with-jquery) – Richard Aug 10 '16 at 07:44
  • use only one function and validate it inside . Add some checks to decide which to run and which not – Amar Singh Aug 10 '16 at 07:45
  • Hi @Sameer, unfortunately the original html which i'm not suppose to touch too, doesn't have id but only class – nicker Aug 10 '16 at 07:50

0 Answers0