-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path57(三种数据调试方法).html
66 lines (50 loc) · 1.39 KB
/
57(三种数据调试方法).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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>三种数据调试方法 dom抓元素</title>
<style type="text/css">
#pink{
background: pink;
margin: auto;
}
</style>
<script type="text/javascript">
window.onload=function(){
//抓取元素
var btn = document.getElementById("btn");
var pink = document.getElementById("pink");
var time;
var wid=5;
var hig=5;
//创建单击事件
btn.onclick = function(){
clearInterval(time);
time = setInterval(function(){
var starWid = pink.style.width;
var newWid = parseInt(pink.style.width)+wid;
pink.style.width= newWid+"px";
var starHig =pink.style.height;
var newHig = parseInt(pink.style.height)+hig;
pink.style.height = newHig+"px";
if (newWid==500&&newHig==500) {
wid =-10,hig=-10;
} else if(newWid==0&&newHig==0){
wid=10,hig=10;
}
// alert(document.title)查看标题
// document.title = "nimeimeid"改标题
//数据调试三种方法
// alert("宽度为:"+newWid);//这个慎得慌
// console.log(newWid);//控制台查看
document.title =newWid;//标题查看
},100)
}
}
</script>
<body>
<input type="button" id="btn" value="点我" />
<div id="pink" style="width:200px;height:200px;">
</div>
</body>
</html>