<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>#box{width:400px; height:500px; border:5px solid #333; background-color:#CCC; position:relative; margin:10px auto;}#prev{width:50px; height:400px; opacity:0.8; position:absolute; left:0px; top:50px; background:#ccc; border:5px solid #000; text-align:center; text-decoration:none; font-size:50px; font-weight:bold; line-height:400px; border-left:none;}#next{width:50px; height:400px; opacity:0.8; position:absolute; right:0px; top:50px; background:#ccc; border:5px solid #000; text-align:center; text-decoration:none; font-size:50px; font-weight:bold; line-height:400px; border-right:none;}#img1{width:400px; height:500px;}#con{ position: absolute; width: 400px; height:30px; left: 0px; bottom:0px; text-align:center; line-height:30px; background:black; margin:0; color:#FFF; opacity:0.5;}#wocao{ position: absolute; width: 400px; height: 30px; left: 0px; top: 0px; text-align:center; line-height:30px; background:black; margin:0; color:#FFF; opacity:0.5;}#box2{text-align:center; margin-top:30px;}</style><script>window.onload = function (){ var oBox2 = document.getElementById('box2'); var oBox = document.getElementById('box'); var oBtn1 = document.getElementById('btn1'); var oBtn2 = document.getElementById('btn2'); var oPrev = document.getElementById('prev'); var oNext = document.getElementById('next'); var oImg = document.getElementById('img1'); var oCon = document.getElementById('con'); var oWo = document.getElementById('wocao'); var arrUrl = ['http://www.9669.com/uploadfile/2015/0824/20150824085615657.png','http://img3.pcgames.com.cn/pcgames/1006/03/1920087_2009062301061245690095_7716_thumb.jpg','http://pic.baike.soso.com/p/20120914/20120914171422-1627901078.jpg','http://img.265g.com/userup/1104/201104291443348880.jpg']; var arrText = ['草稚京','八神庵','卢卡尔','大蛇']; var num = 0; function fnTab(){ oWo.innerHTML = num+1 +' / '+ arrText.length; oCon.innerHTML = arrText[num]; oImg.src = arrUrl[num]; } fnTab(); oPrev.onclick = function (){ num --; fnTab(); }; oNext.onclick = function (){ num ++; fnTab(); }; };</script> </head><body><div id="box2"> <input id="btn1" type="button" value="循环点击"> <input id="btn2" type="button" value="顺序点击"></div><div id="box"> <a href="" id="prev"/><</a> <a href="" id="next"/>></a> <img id="img1"/> <p id="con">图片正在加载中......</p> <p id="wocao">数量正在计算中......</p></div></body></html>
3 回答
hxh_kylin
TA贡献33条经验 获得超10个赞
oPrev.onclick = function (){
num --;
fnTab();
};
oNext.onclick = function (){
num ++;
fnTab();
};
这两处写错了,应该是
oBtn1.onclick = function (){
num --;
fnTab();
};
oBtn2.onclick = function (){
num ++;
fnTab();
};
添加回答
举报
0/150
提交
取消