简体   繁体   中英

Javascript stop second setTimeOut function

I have a JS library where on submit form setTimeOut function executes.

I want to execute another setTimeOut function before or after form submission and don't want to execute the setTimeOut function that is in the JS library on submit event.

I can not/don't want to declare like myVar = setTimeout in library so that later I can use clearTimeout(myVar); to clear the timeout function in the library from my end.

Any idea?

For example:

library.js

Form submit event handler with timeout function

contact.html

$('#contact').submit();
setTimeout(function() {
    //some tasks here and dont execute library.js timeout function
}, 5);

I didn't find any good solution but I have now a temporary solution just increase the timer+1. Means if we have 1000ms in library as mentioned in the question, I run another timeout function with 10001ms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM