<input type="text" id='demo'/>
<span id='show'></span>
<br>
<input type="text" id='demo2'/>
<span id='show2'></span>
<script>
function debounce (func, delay) {
var timer;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
func.apply(context, args);
}, delay);
}
}
function update (e) {
show.innerText = this.value;
}
function update2 () {
show2.innerText = this.value;
}
demo.oninput = debounce(update, 300);
demo2.oninput = debounce(update2, 600);
setTimeout定时器写的防抖动
猜你喜欢
转载自blog.csdn.net/jerryyang_2017/article/details/80854604
今日推荐
周排行