温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

JS实现的tab切换选项卡效果示例

发布时间:2020-09-26 11:41:48 来源:脚本之家 阅读:169 作者:小炒花生米 栏目:web开发

本文实例讲述了JS实现的tab切换选项卡效果。分享给大家供大家参考,具体如下:

<script type="text/javascript">
/*
tab切换选项卡js效果   writed by *** 2010.08.13
1.currentid:string 当前被激活菜单的id;
2.otherids:Array() 其它未被激活的id;
3.tabclasses:Array() tab被激活时的样式类+tab未被激活时的样式类,存储两个值即可
*/
function chaneTab(currentid,otherids,tabclasses){
  var tagPrefix="tab";
  var conPrefix="con";
  //显示:
  document.getElementById(tagPrefix+currentid).className=tabclasses[0];
  document.getElementById(conPrefix+currentid).style.display="block";
  //隐藏:
  for(var i=0;i<otherids.length;i++){
    document.getElementById(tagPrefix+otherids[i]).className=tabclasses[1];
    document.getElementById(conPrefix+otherids[i]).style.display="none";
  }
}
</script>

应用代码:

<div class="right_centerzbt ml10">
   <div class="tou">
    <ul class="mt50">
      <li onmouseover="chaneTab('001',new Array('002'),new Array('center_bj',''))" id="tab001" class="center_bj"><a>名山明星榜</a></li>
      <li onmouseover="chaneTab('002',new Array('001'),new Array('center_bj',''))" id="tab002"><a>热门群组</a></li>
    </ul>
   </div>
  <div id="con001"  class="right_content1 l bl br bb">
      <iframe width="680" height="391" frameborder="0" scrolling="no"  border="0" marginheight="0" marginwidth="0" src="shequ/uchome/do.php?ac=ajax&amp;op=getindexspace"></iframe>   
  </div>
  <div id="con002"  class="right_content1 l bl br bb">
          <ol class="mt10 ml10">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=23" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142654112531.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=23" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>武林英雄官方群</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=23" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5"></li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
          <ol class="mt10 ">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=14" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142678521940.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=14" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>游戏贴图</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=14" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5">这里是维客分享与会员互动区。您的...</li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
          <ol class="mt10 ml10">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=20" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/12814265524528.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=20" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>三国群英传官方群</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=20" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5"></li>
    <li class="ml5">主题:<span>1</span>,贴数:<span>1</span></li>
   </ol>
          <ol class="mt10 ">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=18" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142657314254.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=18" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>飘渺仙剑客服群</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=18" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5"></li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
          <ol class="mt10 ml10">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=17" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142658426959.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=17" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>武林英雄客服群</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=17" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5"></li>
    <li class="ml5">主题:<span>1</span>,贴数:<span>1</span></li>
   </ol>
          <ol class="mt10 ">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=25" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/12814265147740.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=25" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>飘渺仙剑官方群</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=25" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5"></li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
          <ol class="mt10 ml10">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=13" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142679512873.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=13" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>游戏交友</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=13" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5">记录管理人员的意见或建议。</li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
          <ol class="mt10 ">
    <li class="quanzi_pic ml10"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=15" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><img onerror="this.onerror=null;this.src='';" src="http://192.168.0.113/shequ/uchome/upload/2010-08/128142677312935.jpg"></a></li>
    <li class="ml5"><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=15" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><b>游戏交易</b></a>(今日:<span><a target="_blank" href="shequ/uchome/space.php?do=mtag&amp;tagid=15" rel="external nofollow" rel="external nofollow" rel="external nofollow" >0</a></span>)</li>
    <li class="ml5">生活中的小窍门,都拿出来和大家分...</li>
    <li class="ml5">主题:<span>0</span>,贴数:<span>0</span></li>
   </ol>
         </div>
 </div>

效果图:

JS实现的tab切换选项卡效果示例

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript切换特效与技巧总结》、《JavaScript遍历算法与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》及《JavaScript数学运算用法总结》

希望本文所述对大家JavaScript程序设计有所帮助。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI