javascript - How can I stop a function early? -
I have created a time-bound function that starts before the delay for 9 seconds after the page starts. However, I would like to cancel it if a user contacts the divi who is affecting it. Here's my code to call the function.
function button changed 4 () {$ (". Button4"). CSS ("background color", "yellow"). Delay (3000) (Work (Next 4) {$ ("Button4"). CSS ("Background Color", "Silver"); Next 4 ();}); }; Var buttonshop3; $ (Document) .ready (function () ($. "Button4"). Delay (9 0000) .Q (function (Nexttoo) {buttonchange4 (); ButtonShop3 = Set enterwall (change button 4, 12000); Nextto ();});});
And my code is to stop the function.
$ ('. Button4'). Click (function () ($ (".button4") .stop (); Clear interval (buttonShop 3); $ ('. Button4'). CSS ("background color", "yellow");});
For some reason, even after a delay of 3 seconds it changes the background color of the button to silver ... it seems that the delay function is stopped and the direct Jump on buttonchange4 ();
How can I stop it?
return;
The function breaks and stops
If you want to break the timerwall then you can do this:
var i = setInterval (function A, 1000 ); Clear interval (i);
Or you can do dequeue () with
: delay
;
$ (".button4") .dequeue ();
Comments
Post a Comment