jquerycodeigniter-3gwtbootstrap3

How to add class active to tab bootstrap after loading window?


Hi all I am a new of jquery I use boostrap 3 and I have the menu tab. and this is my code menu bootstarp and jquery:

<script type="text/javascript">
 $(document).ready(function(){
  $("#tabs").click(function(){
    $(this).addClass("active");
  });
  });
</script>
<div id="nav_left" class="col-md-9">
  <ul id="navigation" class="nav nav-tabs">
    <li id="tabs"><a href="<?php echo base_url().'./site/burger' ?>">Burger</a></li>
    <li><a href="<?php echo base_url().'./site/sides' ?>">Sides</a></li>
    <li><a href="<?php echo base_url().'./site/beverages' ?>">Beverages</a></li>
    <li><a href="<?php echo base_url().'./site/make_own_burger' ?>">Make Your Own Burger</a></li>
    <li><a href="<?php echo base_url().'./site/download' ?>">Download Menu</a></li>
  </ul>

Example When I ckick on menu burger while loading window it is add class. but when finish loading window it remove class .How Can I add class when finish loading window ?


Solution

  • Hi all very thank q for helping .but now I can find correct code now the correct code is :

    <li class="<?php if($this->uri->segment(2)=="burger"){echo "active";}?>" href="<?=base_url('search')?>"><a href="<?php echo base_url().'./site/burger' ?>">Burger</a></li>