发布网友 发布时间:2024-10-23 23:41
共1个回答
热心网友 时间:2024-11-02 17:26
你上面的代码乱了,我帮你写了个很简单的4个图片切换,你可以参考一下!
<div id="img1" style="display:none ">
<img src="1.jpg" border="0" width="480" height="450">
</div>
<div id="img2" style="display:none ">
<img src="2.jpg" border="0" width="383" height="278">
</div>
<div id="img3" style="display:none ">
<img src="3.jpg" border="0" width="383" height="278">
</div>
<div id="img4" style="display:none ">
<img src="4.jpg" border="0" width="383" height="278">
</div>
<script language="javascript">
var len=4;
var times=500;
var thisis=0;
function jpgto()
{
if(thisis>len){thisis=0;}
switch (thisis)
{
case 1:
img1.style.display="";
img2.style.display="none";
img3.style.display="none";
img4.style.display="none";
break;
case 2:
img1.style.display="none";
img2.style.display="";
img3.style.display="none";
img4.style.display="none";
break;
case 3:
img1.style.display="none";
img2.style.display="none";
img3.style.display="";
img4.style.display="none";
break ;
case 4:
img1.style.display="none";
img2.style.display="none";
img3.style.display="none";
img4.style.display="";
break;
}
thisis++;
}
var s=window.setInterval('jpgto()',times);
</script>