切换卡
javascript的tab切换原理与效果
<html>
<head>
<style type="text/css">
#container{border:solid 1px green;width:300px;height:300px;}
li{float:left;margin-left:20px;}
p{float:left;}
#sports,#military,#bbs{display:none;}
</style>
<script type="text/javascript">
function tab(pid){
var ps = ['news','sports','military','bbs'];
for(var i=0,len=ps.length;i<len;i++){
if(ps[i] == pid){
document.getElementById(ps[i]).style.display = "block";
}else{
document.getElementById(ps[i]).style.display = "none";
}
}
}
</script>
</head>
<body>
<div id="container">
<ul>
<li onmouseover="tab('news');">新闻</li>
<li onmouseover="tab('sports');">体育</li>
<li onmouseover="tab('military');">军事</li>
<li onmouseover="tab('bbs');">论坛</li>
</ul>
<p id="news">新闻新闻新闻新闻新闻</p>
<p id="sports">体育体育体育体育体育</p>
<p id="military">军事军事军事军事军事</p>
<p id="bbs">论坛论坛论坛论坛论坛</p>
</div>
</body>
</html>
转自别处,非自己创作。。。。。。。。。