jQuery remove active class

jQuery remove active class

HTML
<ul class="list">
   <li class="active"></a>Home</a></li>
   <li><a>About</a></li>
   <li><a>Contact</li>
   <li><a>Gallery</li>
</ul>
CSS
 ul{
     list-style-type:  none;
 }

 ul li{ 
   margin: 10px 0px;
   padding: 15px;
   text-align: center;   
 }

 ul li a{
    color: #587aaf;
    text-transform: uppercase;
   
 }

.active{
    background: #9bd0eb;
}
Javascript
  $('.list').on('click', 'li', function() {
    $('.list li.active').removeClass('active');
    $(this).addClass('active');
});
679 Views
78140cookie-checkjQuery remove active class

Leave a Reply

Your email address will not be published. Required fields are marked *