限制refreshid Jquery的循环计数?

限制refreshid Jquery的循环计数?,jquery,loops,count,limit,repeat,Jquery,Loops,Count,Limit,Repeat,我确信我已经把它杀掉了,但是我试图限制refreshID变量重复的次数,不是延迟,而是总量。如果有人能帮我保持简单,我会非常感激 $(document).ready(function(){ count = 0; limit = 5; var refreshId = setInterval( function(){ $( ".feed-load-more-container .yt-uix-button" ).click(); }, 5000); });

我确信我已经把它杀掉了,但是我试图限制
refreshID
变量重复的次数,不是延迟,而是总量。如果有人能帮我保持简单,我会非常感激

$(document).ready(function(){
    count = 0;
    limit = 5;

    var refreshId = setInterval( function(){
        $( ".feed-load-more-container .yt-uix-button" ).click(); }, 5000);
});

使用
clearInterval()
方法。因此,在匿名函数中,检查count是否 像这样:

$(document).ready(function(){

count = 0; limit = 5;

var refreshId = setInterval( function() {
    if(count < limit) {
        $( ".feed-load-more-container .yt-uix-button" ).click();
        count++;
    }
    else {
        clearInterval(refreshId);
    }
    }, 5000);

});
$(文档).ready(函数(){
计数=0;极限=5;
var refreshId=setInterval(函数(){
如果(计数<限制){
$(“.feed load more container.yt uix按钮”)。单击();
计数++;
}
否则{
clearInterval(刷新ID);
}
}, 5000);
});

这让我无需点击即可在youtube上自动加载更多视频,感谢againGlad的帮助。当我遇到问题时,这个社区会帮助我:)这也会每隔5秒自动单击将url添加到播放列表以节省时间$(document).ready(函数(){var refreshId=setInterval(函数(){$(“.playlist add video url button add”)。click();},5000);});