I have navigation in form of ul and li. If url is http://mydomain.com/somewiredpath/page21.htm?p=1
how can i get li element with this url? I don't care about rest of the url, need just li with "page21.htm".
<ul id="navig">
<li>
<a href=".../page1.htm"><imgsrc="..."></a>
</li>
<li>
<a href=".../page2.htm"><imgsrc="..."></a>
<ul>
<li><a href=".../page3.htm"><imgsrc="..."></a></li>
<li><a href=".../page4.htm"><imgsrc="..."></a></li>
</ul>
</li>
</ul>
PS: i'm going to add some styles to matched and parent elements, so if there is already some jquery function/plugin for that, it would be great to know.开发者_JS百科
function findLi(pagename) {
return $('#navig a[href*="' + pagename + '"]').closest("li");
}
精彩评论