在我的代码中,按钮 .getmore 在向下滚动时被点击。它从数据库加载数据。工作正常。我需要在每次点击后将其禁用 5 秒。我该如何设置这个延迟计时器?
或者是否可以在触发后将此功能禁用 5 秒?禁用按钮或禁用任何功能对我有用。
$(window).scroll(function(){
if ($(document).height() <= $(window).scrollTop() + $(window).height()) {
// Here how can i set a delay time of 5 sec before next click
$('.getmore').click();
}
});
最佳答案
您可以使用 jQuery 的 setTimeout() 函数。
$('.getmore').prop('disabled', true);
setTimeout(function() {
$('.getmore').prop('disabled', false);
}, 5000);
关于javascript - 如何在第一次点击后禁用此按钮 5 秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41839905/