tab

 1 function tab(pid){
 2     var ps =['mli','news','people','tech'];
 3 
 4     for(var i=0 ,len = ps.length;i<len;i++){
 5         if(ps[i] == pid){
 6             document.getElementById(ps[i]).style.display ='block';
 7         }else{
 8             document.getElementById(ps[i]).style.display ='none';
 9         }
10     }
11 }
12 <body>
13     <div>
14         <ul>
15             <li onmouseover="tab('mli');">军事</li>
16             <li onmouseover="tab('news');">新闻</li>
17             <li onmouseover="tab('people');">人物</li>
18             <li onmouseover="tab('tech');">科技</li>
19         </ul>
20         <p id="mli">军事频道</p>
21         <p id="news">新闻频道</p>
22         <p id="people">人物频道</p>
23         <p id="tech">科技频道</p>
24     </div>
25 </body>

 

posted @ 2014-11-05 15:58  王孙将归  阅读(639)  评论(0编辑  收藏  举报