Not able to add a class to the parent
- <ul id="menu">
<li><a href="#"><strong>Electors</strong></a>
<ul>
<li><a href="A.asp">Conditions Required</a></li>
<li><a href="B.asp">Verification of Entry</a></li>
<li class="submenu"><a href="#">Special Measures</a>
<ul>
<li><a href="C.asp">Documents of cultural communities</a></li>
<li><a href="D.asp">Measures for remote regions</a></li>
</ul>
</li>
<li><a href="E.asp">In case of dissatisfaction</a></li>
</ul>
</li>
<li><a href="#"><strong>Parties and candidates</strong></a>
<ul>
<li><a href="F.asp">Training sessions</a></li>
<li><a href="G.asp">Key dates</a></li>
<li class="submenu"><a href="#">Political financing and control of election expenses</a>
<ul>
<li><a href="H.asp">Official</a></li>
<li><a href="I.asp">Returns</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#"><strong>Media</strong></a>
<ul>
<li><a href="J.asp">General information</a></li>
<li><a href="K.asp">Candidature</a></li>
</ul>
</li>
</ul>
<script type="text/javascript">
$(document).ready(function(){
$("#menu a[href='<% response.write get_cur_page %>']").closest().addClass("active");
});
</script>
With the above code, i want to add the "active" class to the <li> tag related to the current page. "get_cur_page" is an ASP function that returns the page so if you are on the page J it will return J.asp.
I cant get this code to work, the goal is to have the "active" class applied to the <li> tag surrounding the active page's link in the menu.
Thx for your help