开发者

jquery - resetting timer

开发者 https://www.devze.com 2022-12-24 05:37 出处:网络
im using a plugin to do something ever 10 secs: function status_updates(){ $(\"p\").everyTime(1000,function(i) {

im using a plugin to do something ever 10 secs:

function status_updates(){
    $("p").everyTime(1000,function(i) { 
        if(i==10){
            alert("foo");
            // something here
        }else{
            $(this).html(i);    
        }
    开发者_开发技巧});
}
status_updates();

where it says something here I need to add something to reset the timer but i dont know how. The plugin is here: http://jquery.offput.ca/every/ or if you know of an other way it would be much appreciated.


If you test with i==10, alert will be triggered just once.

Try with this:

function status_updates(){
    $("p").everyTime(1000,function(i) { 
        if(i % 10 == 0){
            alert("foo");
            // something here
        }else{
            $(this).html(i);    
        }
    });
}
status_updates();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号