I am trying to add an active class to li based on the active URL, This what I got, unfortunately, it is not working when the
<li class="scroll"><a href="index.php">Home</a></li>
and it will work when :
<li class="scroll"><a href="">Home</a></li>
The jQuery is:
jQuery(function($) {
var path = window.location.href;
if ( path == '' ) {
path = 'index.php';
}
$('ul li a').each(function() {
if (this.href === path) {
$(this).parent().addClass('is-current');
}
});
});
Thank you!