Jquery 1.4.2 equivalent for setTimeout and clearTimeout

Is there any equivalent for the setTimeout and clearTimeout functions in jquery 1.4.2 .... I found this ex that uses jquery 1.3.2 ..

 var alerttimer = window.setTimeout(function () { $alert.trigger('click'); }, 3000); $alert.animate({height: $alert.css('line-height') || '50px'}, 200) .click(function () { window.clearTimeout(alerttimer); $alert.animate({height: '0'}, 200); }); 
+4
source share
2 answers
 $(document.body).delay(3000).show(1, function(){ // do something }); 

which will use jQuerys fx queueing to create a timeout. To emulate an interval this way, use a function that calls itself when the callback closes.

 function repeat(){ // do something $(document.body).delay(5000).show(1, repeat); } 

Use $(document.body).stop() to clear the fx queue and stop the interval.

This is similar to the javascript setTimeout hack interval.

 (function(){ alert('I popup every 5 seconds! haha!'); setTimeout(arguments.callee, 5000); })(); 
+3
source

setTimeout and clearTimeout are native JavaScript methods, so they also work in jQuery 1.4.2. - and as such there is no need for equivalents in jQuery.

+4
source

Source: https://habr.com/ru/post/1313476/


All Articles