关于JS选项卡的问题
<html><head><style>input{background:#ccc;}div{height:200px;width:200px;background:#cc...
<html>
<head>
<style>
input {background:#ccc;}
div {height:200px; width:200px; background:#ccc; display:none;}
.active {display:block;}
.now { background:yellow;}
</style>
<script>
window.onload=function()
{
var oBnt=document.getElementsByTagName('input');
var oDiv=document.getElementsByTagName('div');
for (var i=0;i<oBnt.length;i++)
{ oBnt[i].index=i;
oBnt[i].onclick=function()
{
for (var i=0;i<oBnt.length;i++)
{
oBnt[i].className='';
odiv[i].style.display='none';
}
this.className='now';
}
oDiv[this.index].className='active';
}
}
</script>
</head>
<body>
<input class='now' type='button' value='1'/>
<input type='button' value='2'/>
<input type='button' value='3'/>
<div class='active'>1111</div>
<div>2222</div>
<div>3333</div>
</body>
</html> 展开
<head>
<style>
input {background:#ccc;}
div {height:200px; width:200px; background:#ccc; display:none;}
.active {display:block;}
.now { background:yellow;}
</style>
<script>
window.onload=function()
{
var oBnt=document.getElementsByTagName('input');
var oDiv=document.getElementsByTagName('div');
for (var i=0;i<oBnt.length;i++)
{ oBnt[i].index=i;
oBnt[i].onclick=function()
{
for (var i=0;i<oBnt.length;i++)
{
oBnt[i].className='';
odiv[i].style.display='none';
}
this.className='now';
}
oDiv[this.index].className='active';
}
}
</script>
</head>
<body>
<input class='now' type='button' value='1'/>
<input type='button' value='2'/>
<input type='button' value='3'/>
<div class='active'>1111</div>
<div>2222</div>
<div>3333</div>
</body>
</html> 展开
推荐于2016-08-08
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8>
<title>recursion</title>
<style type="text/css">
input {
background: #ccc;
}
div {
height: 200px;
width: 200px;
background: #ccc;
display: none;
}
.active {
display: block;
}
.now {
background: yellow;
}
</style>
<script type="text/javascript">
window.onload = function ()
{
var oBnt = document.getElementsByTagName ('input');
oBnt.index = 0;
var oDiv = document.getElementsByTagName ('div');
var anonymous = function (i)
{
oBnt[i].onclick = function ()
{
if (oBnt.index >= 0)
{
oBnt[oBnt.index].className = '';
oDiv[oBnt.index].className = '';
}
this.className = 'now';
oDiv[i].className = 'active';
oBnt.index = i;
}
};
for ( var i = 0; i < oBnt.length; i++)
{
anonymous (i);
}
}
</script>
</head>
<body>
<input class='now' type='button' value='1' />
<input type='button' value='2' />
<input type='button' value='3' />
<div class='active'>1111</div>
<div>2222</div>
<div>3333</div>
</body>
</html>
追问
大哥收徒吗
追答
为何有此一问
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询