I have a little code using jquery and I want to wait like, 300ms and then change a variable. I tried setTimeout but it wouldn’t work, it just made the variable change instantly.
setTimeout(animationWait = 0, 300);
(I defined animationWait earlier globally in the document) Basically what I’m trying to do is wait for a click to end before another click can be done. So i thought I’d set a variable and then wait 300ms,
$('#up-arrow').live('click', function(e) {
if(animationWait == 0) {
animationWait = 1;
.... /* Code */
}
}
So I need to change the animationWait back to 0 again after a delay to run the code. I’ve tried a bunch of stuff but it’s still not working, any ideas?
You are not using setTimeout quite right. It must be passed either a function name or an anonymous function.