<!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);
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:
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>
<p 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"
/ alt=
"jsでのスイッチ変数の使用"
>
</p>
</body>
</html>