Q:

How to select top most  element in a hierarchical menu in jQuery?

I'm implementing a menu bar using jQuery with a nested set of <ul> lists, where each <li> contains an <a> tag.  Given that I can match the specific <a> tag via the href attribute, how can I walk the menus so I arrive at the top most enclosing <li> element?
I need that so I can set a class="current" which changes the highlighting to reflect the newly selected item.
EDIT: To everyone who responded, thank you.  It was an education, as usual.  I ended up using @PKG's solution... it fit perfectly into my implementation.

A:

The function below will return the top level <li> only
$(this).parents("li").last();

