-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_arr.html
70 lines (38 loc) · 1.07 KB
/
test_arr.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
/*console.log([0]=="0");
console.log(+[]);
console.log(+{});
console.log([[]][0]==[]);
console.log([]+1);
console.log(++[[]][+[]]+[+[]]);*/
function $(id){
return document.getElementById(id);
}
var timer = null;
function move(){
var oDemo = $('demo');
var speed = 1;
clearInterval(timer);
timer = setInterval(function(){
if(oDemo.offsetLeft>=300){
clearInterval(timer);
}else{
oDemo.style.left = oDemo.offsetLeft+speed+'px';
}
},30);
}
</script>
<style type="text/css">
#demo{width: 100px;height: 100px;background: skyblue;position: absolute;left: 0;top: 30px;}
</style>
</head>
<body>
<input type="button" onclick="move()" value="运动" />
<div id="demo"></div>
</body>
</html>