I am adding class="active" in nav > ul >li by jQuery for changing background color . Its working when href="#" . But when I am adding link in between href="example.php" - its go to the page . but active class is not working and background is not remaining to show where I am .
is it possible link work and also background change to show which page I am now by jQuery or how they do in WP ?
$(document).ready(function(){
$(".menu").on('click','li', function(){
$(".menu .active").removeClass('active');
$(this).addClass('active');
} );
} );
<ul class="menu">
<li class="active"><a href="index.php">Home</a></li>
<li><a href="bestdeal.php">Best Deal</a></li>
<li><a href="#">Shop</a>
<ul>
<li><a href="#">Sub menu</a></li>
<li><a href="#">Sub menu</a></li>
</ul>
</li>
<li><a href="#">About Us</a>
<ul>
<li><a href="#">Sub menu</a></li>
<li><a href="#">Sub menu</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a></li>
</ul>