Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove and add active class with jquery

$(document).ready(function () {
    $('.nav li').click(function(e) {

        $('.nav li').removeClass('active');

        var $this = $(this);
        if (!$this.hasClass('active')) {
            $this.addClass('active');
        }
        //e.preventDefault();
    });
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #add #active #class #jquery
ADD COMMENT
Topic
Name
7+4 =