How to change the backlight menu by using js?

Here is my menu



    And here is the script
    $('ul a').each(function () {
    if (this.href == location.href) $(this).parent().addClass('active')

    });

    How to make so that when you click on not the main element was removed from the class to the main li ?
July 4th 19 at 23:28
1 answer
July 4th 19 at 23:30
$('ul a').click(function(){
 $('ul a').each(function () {
 if($(this).parent().attr('class') == 'active')
$(this).parent().removeClass('active');
});
});


The problem You have is not true worth. Wat You a rough answer to Your question, but you can make more elegant and knowing more about Your code page

Find more questions by tags User's navigationYii