OnKeyUp JavaScript时间延迟? [英] OnKeyUp JavaScript Time Delay?

查看:189
本文介绍了OnKeyUp JavaScript时间延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好再次网络大师:)
现在,我有一个新的愚蠢问题,我要求原谅我。我到处都读到了这个解决方案,但找不到适用于我的解决方案。

Hi Again Masters Of The Web :) Now, I have got a new stupid question, and I am asking to forgive me. I read everywhere about this solution, but didn't find the one that works for me.

我有:

<input name="domain" type="text" id="domain" onKeyUp="javascript:chk_me();">

我要问的是如何在按下按钮后不检查,但是说1000毫秒的键盘不活动?

All I am asking is how to make this not to check after a button is pressed, but after to say 1000 miliseconds of keyboard inactivity?

推荐答案

试试这个:

var timer;
function chk_me(){
   clearTimeout(timer);
   timer=setTimeout(function validate(){...},1000);
}

这样每次按下一个键,超时都会被删除,再次设置。

In this way every time a key is pressed, the timeout will be deleted and the set again.

这篇关于OnKeyUp JavaScript时间延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆