forked from anbang/javascript-notes
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-file.html
More file actions
37 lines (36 loc) · 881 Bytes
/
test-file.html
File metadata and controls
37 lines (36 loc) · 881 Bytes
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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="test.css"/>
<style>
#test{
width: 200px;height: 200px;background-color: #002d32;
position: absolute;
top: 300px;
left: 20px;
}
</style>
</head>
<body>
<div id="test">2222222222</div>
<script>
var div = document.getElementById("test");
var left;
var timer=setTimeout(function(){
//处理中
left = parseFloat(window.getComputedStyle(div,null).left)+5;
console.log(left);
div.style.left = left + "px";
if (left < 200) {
setTimeout(arguments.callee, 500);
console.log("star agin ");
}else{
console.log("clear Timeout");
clearTimeout(timer);
}
}, 10);
</script>
</body>
</html>