As you know, events usually appear in javascript, so the event handler that fires the event is executed first, then the parent's event handler is called, and so on. This behavior causes some problems in the project I'm working on now, I would prefer to change the order of execution.
I calculated a solution using timeouts:
$(element).mouseover(function(){ var that = this; setTimeout(function() {
So, basically, event handlers are executed after a short timeout, the wait time depends on the depth of the element in the DOM tree: the event handler of the html element is executed immediately, the event handler of the body element is executed after 1 ms, etc. Thus, the execution order of events is canceled.
The results of my first tests are positive, but I'm still not sure if there are any problems or flaws with this solution. What do you think of this decision? Other ideas on how to solve these problems are also much appreciated.
Simon
source share