jquery - remove class active from first parent in accordion -


i have following problem. when click li element adds class active when click li element expand second level menu adds class active , correct when click example second level link adds class active parent li ul inside still has class active how remove class???

<ul class="nav-stacked"> <li><a href="#">link</a> <li><a href="#">link 1</a> <li><a href="#">link 2</a> <ul class="dropdown"> <li><a href="#">second level link</a></li> </ul> </li> <li><a href="#">link 3</a></li> </ul> 

jquery

        $(".nav-stacked > li").click(function() {         $(".nav-stacked > li").removeclass("active");         $(this).addclass("active");         }); 

why dont try removing active classes , after add again active class?

$(".nav-stacked > li").click(function() {     $(".active").removeclass("active");     $(this).addclass("active");     }); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -