开发者

jQuery resume setInterval timer on keystroke

开发者 https://www.devze.com 2022-12-21 04:31 出处:网络
I have a jQuery setInterval function named \"timerIncrement\" that times out (stops incrementing the variable [licount]) after x-seconds.to resume this interval I have a .mousemove function which look

I have a jQuery setInterval function named "timerIncrement" that times out (stops incrementing the variable [licount]) after x-seconds. to resume this interval I have a .mousemove function which looks like this:

$(this).mousemove(function(){ licount = 0; timerIncrement(); });

what I'm looking for is a way to do this exact thing (resume the timerIncrement function) if a 开发者_如何学运维keystroke is made.

Can someone please help with this...


$(this).keypress(function(){ licount = 0; timerIncrement(); });

By the way, if you want the keypress to trigger on the entire document, it may be better to use "document" instead of "this"... perhaps in both situations:

$(document).keypress(function() { licount = 0; timerIncrement(); });

See more here.

0

精彩评论

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

关注公众号