效果图:
代码如下:
复制代码
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> *{ margin: 0; padding: 0; font-family: "微软雅黑"; } #wrap{ width: 400px; height: 500px; border: 1px solid #ccc; margin: 20px auto; position: relative; overflow: hidden; background: #f1f1f1; } #wrap a{ width: 40px; height: 50px; background:rgba(0,0,0,.4); /*border: 1px solid #fff;*/ position: absolute; top: 50%; margin-top: -25px; text-align: center; text-decoration: none; line-height: 50px; color: white; font-size: 30px; } #wrap a:hover{ background:rgba(0,0,0,.9); } #prev{ left: 10px; } #next{ right: 10px; } #note,#span1{ position: absolute; left: 0; width: 400px; height: 30px; line-height: 30px; text-align: center; color: white; background: rgba(0,0,0,.6); } #note{ bottom: 0; } #span1{ top: 0; } #img1{ width: 400px; height: 500px; } section{ width: 400px; height: 50px; margin: 30px auto 0; line-height: 50px; text-align: center; } section input{ padding: 5px 15px; margin-right: 10px; } .pink{ background: pink; color: white; } </style> </head> <script> window.onload=function(){ var oPrev=document.getElementById('prev'); var oNext=document.getElementById('next'); var oNote=document.getElementById('note'); var oSpan=document.getElementById('span1'); var oImg=document.getElementById('img1'); var arrURL=['https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488463139&di=af377bee44237b092b20f1f7c86f2eb6&imgtype=jpg&er=1&src=http%3A%2F%2Fwww.wed114.cn%2Fjiehun%2Fuploads%2Fallimg%2F160304%2F52_160304170213_3.jpg','https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488463080&di=a0ba47cd212e8f5755a2f42738511a2e&imgtype=jpg&er=1&src=http%3A%2F%2Fwww.6a8a.com%2Fuploadfile%2F2017%2F0809%2F2016071617592321137.jpg','https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488463040&di=f9290db609a0994bdbd7221e644904ba&imgtype=jpg&er=1&src=http%3A%2F%2Fwww.wed114.cn%2Fjiehun%2Fuploads%2Fallimg%2F160405%2F52_160405165047_3.jpg','https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488462814&di=e1dacd05467c01a13d9eb4d800853f20&imgtype=jpg&er=1&src=http%3A%2F%2Fwww.wed114.cn%2Fjiehun%2Fuploads%2Fallimg%2F160304%2F52_160304160734_5.jpg','https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487868087852&di=3011f4a2b23b63559c32f8f154ad0a3a&imgtype=0&src=http%3A%2F%2Fwww.wed114.cn%2Fjiehun%2Fuploads%2Fallimg%2F160411%2F52_160411172520_1.jpg']; var arrNote=['多肉植物佛珠怎么养 翡翠珠的养殖方法','多肉植物紫弦月的养殖方法','多肉植物球松怎么养 球松的养殖方法','是一种小巧又可爱的 多肉植物','多肉植物蓝松怎么繁殖']; var num=0; var oBtn=document.getElementsByTagName('input'); var onOff=true; oBtn[0].onclick=function(){ onOff=true; this.className='pink'; this.nextSibling.className=''; } oBtn[1].onclick=function(){ onOff=false; this.className='pink'; this.previousSibling.className=''; } function fnTab(){ oSpan.innerHTML=num+1+'/'+arrURL.length; oImg.src=arrURL[num]; oNote.innerHTML=arrNote[num]; } fnTab(); oPrev.onclick=function(){ num--; if(num==-1){ if(onOff){ num=arrNote.length-1; }else{ alert('已经是第一张图片了,亲!'); num=0; } } fnTab(); } oNext.onclick=function(){ num++; if(num==arrNote.length){ if(onOff) { num=0; }else{ alert('已经是第一张图片了,亲!'); num=arrNote.length-1; } } fnTab(); } } </script> <body> <section> <input type="button" value="循环播放" class="pink"/><input type="button" value="顺序播放" /> </section> <div id="wrap"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" id="prev"><</a> <a href="javascript:;" rel="external nofollow" rel="external nofollow" id="next">></a> <p id="note">图片文字加载中......</p> <span id="span1">数量正在计算中......</span> <img id="img1" /> </div> </body> </html>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!
最后
以上就是动人硬币最近收集整理的关于js中开关变量使用实例的全部内容,更多相关js中开关变量使用实例内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复