This topic contains 0 replies, has 1 voice, and was last updated by Sravan Kumar 6 years, 4 months ago.
- August 30, 2012 at 10:22 pm #4023
We generally do setTimeout as
setTimeout("SomeFunction();", 5000); // Means setTimeout is set to 5 seconds
Some defined or custom function in our case it is SomeFunction() which will run after 5 seconds.
But what if you want to cancel or clear or avoid setTimeout after few seconds and before the function SomeFunction() is initiated?
In this condition we need to use clearTimeout function.
Generally to cancel or clear some timeout stuff – the best way to do is the following
1. Put setTimeout in some variable, something like this
var timer = setTimeout("SomeFunction();", 5000);
2. Then now to cancel or clear it, do the following
You must be logged in to reply to this topic.