This doesn't seem to work in Jquery
$(document).ready(function() {
$(".navlist li").each(function() {
var href = $(this).find("a").attr("href");
if ($(this).find("a").attr("href") == window.location.pathname) {
$(this).attr("class", "active");
}
});
});
in my html
<div id="main-navigation">
<ul class="navlist">
<li><a href="<%=ResolveUrl("~/home.aspx")%>">home</a></li>
<li><a href="<%=ResolveUrl("~/sample-templates/view-list.aspx")%>">manage sample templates</a></li>
<li><a href="<%=ResolveUrl("~/fractional-templates/manage.aspx")%>">manage fractional templates</a></li>
<li><a href="<%=ResolveUrl("~/faq.aspx")%>">faq</a></li>
</ul>
</div>
in my css
.navlist li.active a
{
color: #fff;
background-color: #369;
text-decoration: none;
}
Any suggestions?
I debugged the js and the problem is that the class is not being added