Skip to content

Instantly share code, notes, and snippets.

@guimeisang
Created September 25, 2018 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guimeisang/b553da51b5ba4128aaaa0f811fb7a19e to your computer and use it in GitHub Desktop.
Save guimeisang/b553da51b5ba4128aaaa0f811fb7a19e to your computer and use it in GitHub Desktop.
debounce // source https://jsbin.com/wadalaz
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>debounce</title>
</head>
<body>
<input type="text" name="keyword" id="j-input" />
<script id="jsbin-javascript">
// 请完善以下代码中的防抖方法
// 当在文本框输入关健词过程中停顿 2 秒后触发自动搜索
var ele = document.getElementById('j-input');
ele.addEventListener('keyup', debounce(function(e) {
console.log('search keyword: ' + this.value);
}, 2000));
function debounce(fn, delay){
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">// 请完善以下代码中的防抖方法
// 当在文本框输入关健词过程中停顿 2 秒后触发自动搜索
var ele = document.getElementById('j-input');
ele.addEventListener('keyup', debounce(function(e) {
console.log('search keyword: ' + this.value);
}, 2000));
function debounce(fn, delay){
}
</script></body>
</html>
// 请完善以下代码中的防抖方法
// 当在文本框输入关健词过程中停顿 2 秒后触发自动搜索
var ele = document.getElementById('j-input');
ele.addEventListener('keyup', debounce(function(e) {
console.log('search keyword: ' + this.value);
}, 2000));
function debounce(fn, delay){
}
@guimeisang
Copy link
Author

防抖功能题目

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment