-
Notifications
You must be signed in to change notification settings - Fork 0
/
控制元素的显示和隐藏.html
98 lines (84 loc) · 2.5 KB
/
控制元素的显示和隐藏.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>IFE ECMAScript</title>
<style>
select {
display: none;
}
.pic {
width: 480px;
height: 480px;
overflow:hidden;
position: relative;
margin-top: 100px;
}
.in {
width: 480px;
height: 8160px;
position: absolute;
top: 0px;
left: 0;
}
</style>
</head>
<body>
<label>
<input id="school" name="status" type="radio">
School
</label>
<label>
<input id="company" name="status" type="radio">
Company
</label>
<select id="school-select">
<option>北京邮电大学</option>
<option>黑龙江大学</option>
<option>华中科技大学</option>
</select>
<select id="company-select">
<option>百度</option>
<option>爱奇艺</option>
</select>
<div class="pic">
<div class="in">
<img src="erik_ce204002.jpg" alt="">
</div>
</div>
<button>笑一个</button>
<script>
//当用户选择了 School 的单选框时,显示 School 的下拉选项,隐藏 Company 的下拉选项
var school = document.querySelector('#school');
var com = document.querySelector("#company");
var sSel = document.querySelector('#school-select');
var cSel = document.querySelector('#company-select');
school.addEventListener('click',function(){
cSel.style.cssText = "display: none;";
sSel.style.cssText = "display: block;";
})
//当用户选择了 School 的单选框时,显示 Company 的下拉选项,隐藏 School 的下拉选项
com.addEventListener('click',function(){
cSel.style.cssText = "display: block;"
sSel.style.cssText = "display: none;";
})
//-----------------------------------------------------------------------------为什么函数不执行也不报错呢
//人物图像利用定时器完成的动画
window.onload = function(){
var incon = document.querySelector('.in');
var btn = document.querySelector('button')
var top = 0;
function move(){
if(top>-8160){
incon.style.top = top + 'px';
top -= 480;
setTimeout(move,100)
}
}
btn.onclick = function(){
move()
}
}
</script>
</body>
</html>