tabCase
2018-10-06 本文已影响0人
Jadon7
<!DOCTYPE html>
<html>
<head>
<title>tabCase</title>
</head>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById('div1');
var aBtn=oDiv.getElementsByTagName('input');
var aDiv=oDiv.getElementsByTagName('div');
for (var i = 0; i < aBtn.length; i++)
{
aBtn[i].index=i;
aBtn[i].onmouseover=function()
{
for (var j = 0; j < aBtn.length; j++)
{
aDiv[j].style.display='none';
aBtn[j].className='';
}
this.className='hve';
aDiv[this.index].style.display='block';
};
}
};
</script>
<style type="text/css">
.content{
width: 300px;
height: 300px;
background: #eee;
display: none;
}
.hve{
border: none;
background-color: #eee;
}
</style>
<body>
<div id="div1">
<input type="button" value="tab1" class="hve">
<input type="button" value="tab2">
<input type="button" value="tab3">
<input type="button" value="tab4">
<div class="content" style="display:block">1111</div>
<div class="content">2222</div>
<div class="content">3333</div>
<div class="content">4444</div>
</div>
</body>
</html>