chatbox中出现10秒未键入后尝试触发蜂鸣音。
考虑在蜂鸣事件中构建一个10秒的定时器,该定时器会在每次击键时重置。有什么想法吗?
发布于 2014-12-02 17:33:09
我猜您所期望的解决方案将类似于以下内容
代码:
var timer;
$('#tArea').keyup(function(){
clearTimeout(timer);
timer = setTimeout(yourAction, 10000); // interval is set to 10s
});
$('#tArea').keydown(function(){
clearTimeout(timer);
});
function yourAction () {
// Your code goes here
alert("You have not typed anything for the past 10 seconds!!");
}检查
https://stackoverflow.com/questions/27244661
复制相似问题