文字框onkeyup,不重複執行

xuxubaby發表於2016-10-26


<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="jquery-1.9.0.min.js"></script>
    <title></title>
    <script type="text/javascript">
$(document).ready(function(){


var timer = null;
$("#xxxx").on({
    keyup: function(){
        clearTimeout(timer);
        timer = setTimeout(function(){
            alert(1);
        }, 1500);
    }
});
});
    </script>
</head>


<body style="margin:0; padding:0; width:100%; height:100%; overflow:hidden">
   <input type="text" id="xxxx" />
</body>
</html>

相關文章