I am trying to highlight the active link, it underlines it, but the underline is suddenly deleted. I canβt understand what I am doing wrong:
$(document).ready(function () {
var str = location.href.toLowerCase();
$('nav ul li a').each(function () {
if (str.indexOf(this.href.toLowerCase()) > -1) {
$('a.active').removeClass('active');
$(this).parent().addClass('active');
}
});
});
HTML:
<nav>
<ul>
<li><a class="active" href="#intro" title="Intro">Intro</a></li>
<li><a href="#what" title="What We Do">What We Do</a></li>
<li><a href="#how" title="How We Do It">How We Do It</a></li>
<li><a href="#modus" title="Our Modus Operandi">Our Modus Operandi</a></li>
</ul>
</nav>
Any help? Thank.
source
share