小菜很迷茫
2015-01-16 10:57
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tab切换</title>
<link rel="stylesheet" type="text/css" href="Untitled-3.css"/>
<script type="text/javascript">
function $( id){ return typeof id ==='string'?document.getElementById(id):id ;
}
window.onload=function (){
//获取鼠标划过标签和内容的元素
var titles=$(notice_tite).getElementsByTagName('li');
divs=$(notic_con).getElementsByTagName('div');
if(titles.length!=divs.length )
return;
for( var i=0;i<titles.length;i++){
titles[i].id=i;
titles[i].onclick=function(){
for( var j=0; j<titles.length;j++){
titles[j].className="";
divs[j].style.display='none';
}
this.className="select";
divs[this.id].style.display='block';
}
}
}
</script>
</head>
<body>
<div id="notice" class="notice">
<div id="notice_tite" class="notice_tite">
<ul>
<li ><a href="#" >公告1</a></li>
<li><a href="#">公告2</a></li>
<li><a href="#">公告3</a></li>
<li><a href="#">公告4</a></li>
<li class="select"><a href="#" >公告5</a></li>
</ul>
</div>
<div id="notic_con" class="notic_con">
<div id="mod" style="display:none;">1</div>
<div id="mod" style="display:none;">2</div>
<div id="mod" style="display:none;">3</div>
<div id="mod" style="display:none;">4</div>
<div id="mod" style="display:block;">5</div>
</div>
</div>
</body>
</html>
。。。
Tab选项卡切换效果
65469 学习 · 533 问题
相似问题