求助,结果运行不出来,firebug显示本页面不包含 JavaScript
求助,结果运行不出来,firebug显示本页面不包含JavaScript<styletype="text/css">#div1.active{background:yel...
求助,结果运行不出来,firebug显示本页面不包含 JavaScript
<style type="text/css">
#div1.active{background: yellow;}
#div1 div{width: 100px;height: 200px;display: none;}
</style>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById("div1");
var oBtn=oDiv.getElementsByTagName("input");
var aDiv=oDiv.getElementsByTagName("div");
for (var i = 0; i<oBtn.length;i++)
{
oBtn[i].index=i;
oBtn[i].onclick=function()
{
for(var i=0;i<oBtn.length;i++;)
{
oBtn[i].className="";
aDiv[i].style.display="none";
}
this.className="active";
aDiv[this.index].style.display="block";
};
}
}
</script>
</head>
<body>
<div id='div1'>
<input type="button" value="1"/>
<input type="button" value="2"/>
<input type="button" value="3"/>
<input type="button" value="4"/>
<div>11</div>
<div>22</div>
<div>33</div>
<div>44</div>
</div>
</body> 展开
<style type="text/css">
#div1.active{background: yellow;}
#div1 div{width: 100px;height: 200px;display: none;}
</style>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById("div1");
var oBtn=oDiv.getElementsByTagName("input");
var aDiv=oDiv.getElementsByTagName("div");
for (var i = 0; i<oBtn.length;i++)
{
oBtn[i].index=i;
oBtn[i].onclick=function()
{
for(var i=0;i<oBtn.length;i++;)
{
oBtn[i].className="";
aDiv[i].style.display="none";
}
this.className="active";
aDiv[this.index].style.display="block";
};
}
}
</script>
</head>
<body>
<div id='div1'>
<input type="button" value="1"/>
<input type="button" value="2"/>
<input type="button" value="3"/>
<input type="button" value="4"/>
<div>11</div>
<div>22</div>
<div>33</div>
<div>44</div>
</div>
</body> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询