求一段让3个div能隔2秒就自动切换一下的js代码,要简洁的,谢谢_百度...

发布网友 发布时间:2022-04-24 20:37

我来回答

2个回答

热心网友 时间:2022-04-23 09:21

var i=1;
function show(j)
{
document.getElementById(i1).style.display = "none";
document.getElementById(2).style.display = "none";
document.getElementById(3).style.display = "none";
document.getElementById(j).style.display = "block";
}
settimerout(function(){show(i);i++;},2000);
}

热心网友 时间:2022-04-23 10:39

function show()
{
setTimeout("changeBody(id)",1000);
}
function changeBody(index){
switch(index){
case 1:{
document.getElementById('iDBody1').style.display = "block";
document.getElementById('iDBody2').style.display = "none";
document.getElementById('iDBody3').style.display = "none";
break;
}
case 2:{
document.getElementById('iDBody1').style.display = "none";
document.getElementById('iDBody2').style.display = "block";
document.getElementById('iDBody3').style.display = "none";
break;
}
case 3:{
document.getElementById('iDBody1').style.display = "none";
document.getElementById('iDBody2').style.display = "none";
document.getElementById('iDBody3').style.display = "block";
break;
}
}
}

<body onload="show()">
</body>

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