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 - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

java - Reading data from multiple zip files and combining them to one -