forked from yangxi0126/javaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
输入框抖动.html
45 lines (45 loc) · 991 Bytes
/
输入框抖动.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
40
41
42
43
44
45
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<title>窗口登陆效果-蚂蚁部落</title>
<style type="text/css">
#win
{
position:relative;
width:100px;
height:100px;
background-color:#666;
}
</style>
<script type="text/javascript">
var a=['top','left'];
var b=0;
var u;
function fudu()
{
win.style[a[b%2]]=(b++)%4<2?"0px":"4px";
if(b>15)
{
clearInterval(u);
b=0
}
}
function zd()
{
clearInterval(u);
u=setInterval(fudu,32)
}
window.onload=function()
{
var bt=document.getElementById("bt");
var win=document.getElementById("win");
bt.onclick=zd;
}
</script>
</head>
<body >
<button id="bt">点击振动</button>
<div id="win"></div>
</body>
</html>