如何在bootstrap上进行切换菜单?

时间:2015-11-10 08:35:33

标签: jquery twitter-bootstrap codeigniter-3

大家好我是一个新的引导程序。当我将broswer缩小到小尺寸它显示菜单时我有切换菜单的问题但是当我点击切换菜单它没有显示菜单我该怎么办?

这是我的代码:

<script type="text/javascript"> 
      $(function(){
      $('#slide-submenu').on('click',function() {             
            $(this).closest('.list-group').fadeOut('slide',function(){
              $('.mini-submenu').fadeIn();  
            });

          });

      $('.mini-submenu').on('click',function(){   
            $(this).next('.list-group').toggle('slide');
            $('.mini-submenu').hide();
      })
    })

    </script>
    <nav id="nav-menu" style="clear:both" class="navbar navbar-default" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a id="hi" class="navbar-brand" href="<?php echo base_url().'./site/index' ?>">Home</a>
        </div>
       <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul id="nav-menu-hi" class="nav navbar-nav">
                <li class="<?php if($this->uri->segment(2)=='burger'){echo "active";} ?>"><a href="<?php echo base_url().'./site/burger' ?>">Menu</a></li>
                <li class="<?php if($this->uri->segment(2)=='promotion'){echo "active";} ?>"><a href="<?php echo base_url().'./site/promotion' ?>">Promotion</a></li>
                <li class="<?php if($this->uri->segment(2)=='events'){echo "active";} ?>"><a href="<?php echo base_url().'./site/events' ?>">Events</a></li>
                <li class="<?php if($this->uri->segment(2)=='contact'){echo "active";} ?>"><a href="<?php echo base_url().'./site/contact' ?>">Contact</a></li>
                <li class="<?php if($this->uri->segment(2)=='about'){echo "active";} ?>"><a href="<?php echo base_url().'./site/about' ?>">About Us</a></li>  
          </ul>
        </div>
      </div>
    </nav>
    </div>

1 个答案:

答案 0 :(得分:2)

您是否检查过控制台是否有错误?你在哪里添加jQuery?如果它在页脚中,则应在其后添加脚本。