Stop a function, if another is running
I have two events on an form input: onMouseOver
and onMouseOut
. The functions that these events run, effect the came content, and each function takes about 2 seconds to complete all the code. Therefore, how do I fix this scenario: If I was to fire the onmouseover
event then onmouseout
, but befor开发者_运维百科e the code can complete for the onmouseout
I fire the onmouseover
event. When I try this screws up all the code, so how do I fix this?
You can't stop one function with another. Javascript events are handled in order one at a time, if your onmouseout
triggers while onmouseover
is still busy, it'll be queued and run when onmouseover
is finished.
Honestly, onmouseanything
events shouldn't take more than a fraction of a second to complete. You need to restructure your app to do less for these events.
精彩评论