Jquery how to add active class & remove class



Jquery how to add active class & remove class

HTML

<div>
        <ul class="list"> 
           <li class="active"> 
<a href="#">  Dashboard  </a> </li>
           <li> <a href="#">  Profile  </a> </li>
           <li> 
  <a href="#"> Schedule  </a> </li>
</ul>

</div>

Jquery

<script>
  $(document).ready(function(){
$('.list li').click(function() {
      $('.list li.active').removeClass('active');
         $(this).addClass('active');
     });
});
</script>
Post A Comment
  • Blogger Comment using Blogger
  • Facebook Comment using Facebook
  • Disqus Comment using Disqus

No comments :

Thanks For visiting Infotech Solutuion Blog