Use jQuery to match current URL to herf in a UL and add class if matched
Use jQuery to match current URL to herf in a UL and add class if matched
HTML
<ul class="nav_cat_archiveli">
<li><a href="/hallo">Test 1 (/hallo)</a></li>
<li><a href="/HTMLPage15.htm">Test 2 (/HTMLPage15.htm)</a></li>
<li><a href="/HTMLPage16.htm">Test 3 (/HTMLPage16.htm)</a></li>
<li><a href="/HTMLPage17.htm">Test 4 (/HTMLPage17.htm)</a></li>
</ul>
CSS
.nav_cat_archiveli
{
list-style: none;
}
a.currentPage
{
color: Red;
background-color: Yellow;
}
JavaScript
$(document).ready(function () {
var windowLocationPathname != "/hallo"; // For testing purpose.
//Or
//var windowLocationPathname = window.location.pathname;
$('ul.nav_cat_archiveli').find('a[href^="' + windowLocationPathname + '"]').addClass('currentPage');
});