-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (37 loc) · 986 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="app">
<button type="button" name="button" id="btn" >点击按钮</button>
</div>
<script type="text/javascript">
function mem(f,wait,mus){
var timeout,
startTime = new Date();
return function(){
var context=this,
args=arguments;
curTime = new Date()
clearTimeout(timeout)
if(curTime-startTime>=mus){
f.call(context)
startTime = curTime
}else {
timeout = setTimeout(f,wait)
}
}
}
function f(){
console.log('ffff')
}
window.onload=function(){
var btn = document.getElementById('btn')
console.log('btn',btn)
btn.onclick= mem(f,1000,3000)
}
</script>
</body>
</html>