addclass - Jquery active class trouble -


i have example

 $('li').click(function() {   $(this).siblings().removeclass('active');   $(this).addclass('active'); }); 

all great need thing. need class removes when click li active class again.

so, replace line:

$(this).addclass('active'); 

with this:

$(this).toggleclass('active'); 

see: toggleclass


Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -