Run default javascript action in event handler
I am trying to figure out how to initiate the default action before anything else happens. In particular, I am using a third party library, and if I use an event handler and call one of their functions, they override the default action. So as a work in progress, I want the default action to happen before their library function is called.
Is there a way to do this?
Many thanks!
+2
source to share
1 answer
I am assuming you mean that you want to call their function after the event has been handled by the browser.
To do this, use the setTimeout
Execute After Delay method .
For example,
//In the event handler:
setTimeout(function() {
//This code will execute 5 milliseconds later, and only after your code finishes.
//Call their function here
}, 5); //That means a 5 millisecond delay.
//You can increase it if you want to.
+4
source to share