Hi I am trying to write a script in Jquery that auto selects the current page link in the main nav. The nav is just a simple UL like this:
<ul id="primaryNav">
<li>
<a href="retail.html">Home</a>
</li>
<li>
<a href="vision.html">Our Vision</a>
</li>
<li>
<a href="context.html">Town in context</a>
</li>
</ul>
My Jquery so far looks like this:
$('#primaryNav').find("a[href='"+window.location.href+"']").each(function(){
$(this).addClass("selected");
});
This doesn't work because I think its selecting the whole URL whereas I just need it to select the last part e.g retail.html or vision.html then add the class .selected
Can anyone please help? Thanks in advance.