M
M
Maxim Kiktev2016-01-17 19:26:15
JavaScript
Maxim Kiktev, 2016-01-17 19:26:15

How to add active for menu on bootstrap?

There is a menu:

<div class="nav2">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
 <!-- Brand and toggle get grouped for better mobile display -->
 <div class="navbar-header">
   <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
     <span class="sr-only"></span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
   </button>
   <a class="navbar-brand" href="/">Anime Plus</a>
 </div>

 <!-- Collect the nav links, forms, and other content for toggling -->
 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
   <ul class="nav navbar-nav">
     <li><a href="/">Новости Аниме</a></li>
     <li><a href="/amv">AMV </a></li>

   </ul>
 </div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>

How to fix the js code to add the active class to the list?
<li><a href="/">Новости Аниме</a></li>
  <li><a href="/amv">AMV </a></li

$(document).ready(function(){
        $('.nav navbar-nav li').hover(
        function() {
            $(this).addClass("active");
            $(this).find('ul').stop(true, true);
            $(this).find('ul').show('fast');
        },
        function() {
            $(this).find('ul').hide('fast');
            $(this).removeClass("active");
        }
    );
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question