Created
September 25, 2018 07:00
-
-
Save guimeisang/b553da51b5ba4128aaaa0f811fb7a19e to your computer and use it in GitHub Desktop.
debounce // source https://jsbin.com/wadalaz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 请完善以下代码中的防抖方法 | |
// 当在文本框输入关健词过程中停顿 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
防抖功能题目