I have a list containing "URLs" for other pages, I am having difficulty getting the URL of the current page and checking if the extracted pathname is in my list of URLs, if there is one I should add the 'active' class to the li that involves the link.
Here is the list mentioned above:
<ul class='nav navbar-nav navbar-right menuHover'>
<li>
<a href='/'>
<span>
Página Inicial
</span>
</a>
</li>
<li class='dropdown'>
<a href='/cursos'>
<span>
Cursos
</span>
</a>
</li>
<li>
<a href='contact3.html'>
<span>
Contato
</span>
</a>
</li>
</ul>
The code below takes the pathname of the URL:
$(document).ready(function() {
$(location).attr('href');
var pathname = window.location.pathname.replace('#', '');
alert(pathname);
});