Posted in Javascript onSeptember 07, 2016
本文实例讲述了JS简单实现tab切换效果的多窗口显示功能。分享给大家供大家参考,具体如下:
<div style=" text-align:center; margin-top:40px;"> <div class="menubox"> <span id="newstab1" class="hover" onmouseover="setTab('newstab',1,3)"> <a href="###" target="_blank">科室新闻</a></span> <span id="newstab2" onmouseover="setTab('newstab',2,3)"> <a href="###" target="_blank">媒体报道</a></span> <span id="newstab3" onmouseover="setTab('newstab',3,3)"> <a href="###" target="_blank">学术研究</a></span> </div> <div class="contentbox"> <div id="con_newstab_1"> <ul> <li><span>2015-09-09</span><a href="###" target="_blank">阅谁问君诵水落清香浮1</a></li> <li><span>2015-08-17</span><a href="###" target="_blank">阅谁问君诵水落清香浮1</a></li> <li><span>2015-08-05</span><a href="###" target="_blank">阅谁问君诵水落清香浮1</a></li> </ul> </div> <div id="con_newstab_2" style="display:none;"> <ul> <li><span>2015-09-09</span><a href="###" target="_blank">阅谁问君诵水落清香浮2</a></li> <li><span>2015-08-17</span><a href="###" target="_blank">阅谁问君诵水落清香浮2</a></li> <li><span>2015-08-05</span><a href="###" target="_blank">阅谁问君诵水落清香浮2</a></li> </ul> </div> <div id="con_newstab_3" style="display:none;"> <ul> <li><span>2015-09-09</span><a href="###" target="_blank">阅谁问君诵水落清香浮3</a></li> <li><span>2015-08-17</span><a href="###" target="_blank">阅谁问君诵水落清香浮3</a></li> <li><span>2015-08-05</span><a href="###" target="_blank">阅谁问君诵水落清香浮3</a></li> </ul> </div> </div> </div> <script type="text/javascript"> function setTab(name,cursel,n){ for(i=1;i<=n;i++){ var menu=document.getElementById(name+i); var con=document.getElementById("con_"+name+"_"+i); menu.className=i==cursel?"hover":""; con.style.display=i==cursel?"block":"none"; } } </script>
效果图:
希望本文所述对大家JavaScript程序设计有所帮助。
JS简单实现tab切换效果的多窗口显示功能
- Author -
onestopweb声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@