求一段让3个div能隔2秒就自动切换一下的js代码,要简洁的,谢谢 30
2个回答
展开全部
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);
}
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);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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>
{
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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询