首页 > 代码库 > tab

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 onm ouseover="tab(‘mli‘);">军事</li>16             <li onm ouseover="tab(‘news‘);">新闻</li>17             <li onm ouseover="tab(‘people‘);">人物</li>18             <li onm ouseover="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>

 

tab