Active Navbar

Active Navbar

I Have the following code for my nav bar . Its a one page website and has 5 sections , each devided by a "Div" tag and given an ID . 

  1. <div class="navbar-collapse collapse">
  2. <ul class="nav navbar-nav pull-right" id="nav">
  3. <li class="active"><a href="#" >Home</a></li>
  4. <li><a href="#gallery">About</a></li>
  5. <li class="dropdown">
  6. <a href="#" class="dropdown-toggle" data-toggle="dropdown">Offerings <b class=" caret"> 
  7. </b> </a>
  8. <ul class="dropdown-menu">
  9. <li ><a href="#" id="home">Diamonds</a></li>
  10. <li><a href="#">Emralds</a></li>
  11. <li><a href="#">EarthStones</a></li>
  12. <li><a href="#">Natural stones</a></li>
  13. </ul>
  14. <li><a href="#process" id="team">Team</a></li>
  15. <li><a href="#contactus">Contact</a></li>
  16. </ul>
  17. </div>
  18. </div>
  19. </div>


I wanted to Use Jquery to select the Element on the Navbar thats active , so i used the Following code 

  1. <script>
  2. $(document).ready(function() {
  3.  $(".nav li").click(function(event) { 
  4.     
  5.       $(".nav li ").removeClass("active"); //Remove any "active" class 
  6.       $("li", this).addClass("active"); //Add "active" class to selected tab // 
  7.       // $(activeTab).show(); //Fade in the active content 
  8. });
  9. });
  10. </script>


The above code was directly copied from a Jsfiddle i found on Stackexchange.com , i am new to Jquery , but i do get the hang of it ? 

heres the JS fiddle link if it helps .  Js Fiddle Link

am i missing something ? 

Thank you . 

Gautam