Javascript jQuery如果类不是';我没有点击x分钟做点什么

Javascript jQuery如果类不是';我没有点击x分钟做点什么,javascript,jquery,time,Javascript,Jquery,Time,我正在尝试确定是否可以设置单击按钮的超时,而不是使用此处显示的空闲按钮: 我希望它与链接类相关, 例如,如果用户在超过2分钟内未单击链接: jQuery if (".linkClass").(idleTime > 2) { alert("Hurry Up!"); } 有什么建议吗?计时器就是你要找的东西。。。 var clickTimeOut=null; $(".linkClass").on("click",function(){ clickTimeOut = se

我正在尝试确定是否可以设置单击按钮的超时,而不是使用此处显示的空闲按钮:

我希望它与链接类相关, 例如,如果用户在超过2分钟内未单击链接:

jQuery

if (".linkClass").(idleTime > 2) {
    alert("Hurry Up!");
  }

有什么建议吗?

计时器就是你要找的东西。。。
var clickTimeOut=null;

$(".linkClass").on("click",function(){
    clickTimeOut = setTimeout(alertTimeOut, 1000*120);
});

function alertTimeOut()
{
   alert("Hurry Up!");
}
也许是这样:

var idleTimerId;
$('.linkClass').on('click', function(event){
  idleTimerId = setTimeout(function(){ alert("Hello"); }, 5000);
});

// in this example the timer will be initialized when the link is clicked first. 
// Then waits 5000ms to fire. if you want to cancel it - call clearTimeout() 
// with idealTimerId;
在这篇优秀的文章中,有更多关于Javascript定时器的信息:


计时器就是您要找的东西。。。 也许是这样:

var idleTimerId;
$('.linkClass').on('click', function(event){
  idleTimerId = setTimeout(function(){ alert("Hello"); }, 5000);
});

// in this example the timer will be initialized when the link is clicked first. 
// Then waits 5000ms to fire. if you want to cancel it - call clearTimeout() 
// with idealTimerId;
在这篇优秀的文章中,有更多关于Javascript定时器的信息:

像那样的东西应该能奏效!这将设置计时器,在10秒后触发警报。如果在此之前单击该按钮,计时器将被清除

var mt;   

function start_timer() {
    mt = setTimeout(function() {
        alert("Hurry Up!");
    }, 12000);
}

function reset_timer() {
    clearTimeout( mt );
    start_timer();
}

$('.linkClass').click(function() {
    reset_timer();
});

start_timer();

像那样的东西应该能奏效!这将设置计时器,在10秒后触发警报。如果在此之前单击该按钮,计时器将被清除。

使用
setTimeout()
。单击按钮后,清除超时并重新启动。当超时执行时,显示您的“快点”
警报
实际上是的……哇,太简单了,tnx!:)使用
setTimeout()
。单击按钮后,清除超时并重新启动。当超时执行时,显示您的“快点”
警报
实际上是的……哇,太简单了,tnx!:)
var mt;   

function start_timer() {
    mt = setTimeout(function() {
        alert("Hurry Up!");
    }, 12000);
}

function reset_timer() {
    clearTimeout( mt );
    start_timer();
}

$('.linkClass').click(function() {
    reset_timer();
});

start_timer();