图片自动切换有问题!高手请进!

发布网友 发布时间:2024-10-23 23:41

我来回答

1个回答

热心网友 时间:2024-11-09 17:49

你上面的代码乱了,我帮你写了个很简单的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>

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com