标签:视频 sub onload 一段 rip none 16px 错误 set
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#div1 .active {background: yellow;}
#div1 div{
width: 200px; height: 200px; background: #ccc; border: 1px solid #999;display: none;
}
</style>
<script type="text/javascript">
window.onload=function (){
var oDiv=document.getElementBy(‘idv1‘);
var aBth=document.getElementsByTagName(‘input‘);
var aDiv=oDiv.getElementsByTagName(‘div‘);
for(var i = 0;i < aBth.length; i++) {
debugger;
aBth[i].index=i;
aBth[i].onclick=function ()
{
aBth[i].className=‘‘;
aDiv[i].style.display=‘none‘;
};
this.className=‘active‘;
aDiv[this.index].style.display=‘block‘;
};
};
</script>
</head>
<body>
<div id="div1">
<input class="active" type="button" value="教育">
<input type="button" value="培训">
<input type="button" value="招生">
<input type="button" value="出国">
<div style="display: block;">111</div>
<div>222</div>
<div>333</div>
<div>444</div>
</div>
</body>
<html>
用chrome打开这段代码,效果如下。
调试方法:






标签:视频 sub onload 一段 rip none 16px 错误 set
原文地址:http://www.cnblogs.com/senhaishusheng/p/7620447.html