Advertisement
asadsuman

Active one page menu when click

May 16th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <!--how to active menu when click bootstrap-->
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  3. <script type='text/javascript'>
  4. $(function(){
  5.  
  6. $('.nav li a').on('click', function(e){
  7.  
  8.  
  9.  
  10. var $thisLi = $(this).parent('li');
  11. var $ul = $thisLi.parent('ul');
  12.  
  13. if (!$thisLi.hasClass('active'))
  14. {
  15. $ul.find('li.active').removeClass('active');
  16. $thisLi.addClass('active');
  17. }
  18.  
  19. });
  20.  
  21. });
  22. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement