<ul>
<li class="topnav">FirstSet
<ul>
<li><a href='1.aspx'/></li>
<li><a href='2.aspx'/></li>
</ul>
</li>
<li class="topnav">SecondSet
<ul>
<li><a href='3.aspx'/></li>
<li><a href='4.aspx'/></li>
</ul>
</li>
</ul>
this is my menu control, when i am on the 1.aspx/2.aspx i need to hightlight the menu FirstSet
$("#nav").find("a[href='" + window.location.pathname + "']").each(function() {
$(this).addClass("activeTab");
});
using the abouve jquery code, i tried to add the class dynamically.
Please let me know if i am missing somethignn in the above jquery.
You don’t need the
each()call:Depending on where nav is, you could probably do this: