I would like to know how to make the selected menu active.
Here's how my html code is and js, I think it's not working because when you redirect to the < a>, loses the js, when I use preventDefault works as I wanted, however it does not go to the menu link.
Can anyone 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>