1
I would like to know how to leave the selected menu active.
It follows how is my html code and js, I believe it is not working because when redirects to the link of the tag < a >, it loses the js, when I use preventDefault works as I wanted, but it does not go to the menu link.
Can someone help me?
$('.item-menu').click(function (e)
{
$('.item-menu').removeClass('active');
$(this).addClass('active');
});
<ul class="menu-main">
<li class="item-menu active"><a class="item-a" href="home.php?p=link">Link</a></li>
<li class="item-menu"><a class="item-a" href="home.php?p=link1">Link 1</a></li>
<li class="item-menu"><a class="item-a" href="home.php?p=link2">Link 2</a></li>
<li class="item-menu"><a class="item-a" href="home.php?p=link3">Link 3</a></li>
</ul>
I got it by php, thank you!
– Gislane