当前位置:   article > 正文

JS实现Bootstrap中的Nav自动轮播切换_js 实现nav切换并添加class

js 实现nav切换并添加class

1.直接上JS

  1. <script>
  2. //Add by liangxin at 2020-10-27 22:34:53
  3. $(function () {
  4. var i = 0;
  5. setInterval(function(){
  6. if(i==5){i=0;} //Nav Count
  7. $('#myTab li:eq('+i+') a').tab('show');
  8. i++;
  9. },5000);
  10. });
  11. </script>

2.Bootstrap中的Nav

  1. <ul id="myTab" class="nav nav-tabs nav-justified">
  2. <li class="active"><a href="#liangxin1" data-toggle="tab">title1</a></li>
  3. <li><a href="#liangxin2" data-toggle="tab">title2</a></li>
  4. </ul>
  5. <div id="myTabContent" class="tab-content">
  6. <div class="tab-pane fade in active" id="liangxin1">
  7. Liangxin test Content1
  8. </div>
  9. <div class="tab-pane fade in active" id="liangxin2">
  10. Liangxin test Content2
  11. </div>
  12. </div>

3.必须引入的资源

  1. <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  2. <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  3. <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/69349
推荐阅读
相关标签
  

闽ICP备14008679号