<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text">
<script src="jQuery v1.11.3.min.js"></script>
<script type="text/javascript">
var n = 0;
function resizehandler() {
console.log(++n);
}
function throttle(method, context, delay) {
clearTimeout(method.tId);
method.tId = setTimeout(function() {
method.call(context);
}, delay);
}
$("input").keyup(function(event) {
throttle(resizehandler, window, 500);
});
</script>
</body>
</html>
javascript函数节流 keyup
最新推荐文章于 2024-02-04 13:58:52 发布