Skip to content

Instantly share code, notes, and snippets.

@guimeisang
Created September 25, 2018 07:04
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/7c93f74e516665c5db80569786953e09 to your computer and use it in GitHub Desktop.
Save guimeisang/7c93f74e516665c5db80569786953e09 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="防抖功能的题目">
<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){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment