How to select parent object of a hyperlink whose href match the requested page/file name using jQuer

Posted by ARS on Stack Overflow See other posts from Stack Overflow or by ARS
Published on 2010-04-22T15:26:19Z Indexed on 2010/04/22 20:13 UTC
Read the original article Hit count: 185

Filed under:

How to select parent object of a hyperlink whose href match the requested page/file name using jQuery?

I have following code

<div>
<div class="menu-head">
<a href="empdet.aspx">employees</a>
<a href="custdet.aspx">customers</a>
</div>
<div class="menu-head">
<a href="depdet.aspx">departments</a>
</div>
<div>

I want a Jquery to change the color of the parent div corresponding a hyperlink. If the user is browsing custdet.aspx the respective parent div background should be changed to red.

Edit: I have a method to retrieve the file name. I just need the right selector to select the parent.

© Stack Overflow or respective owner

Related posts about jQuery