Is there a built in function in jQuery that would allow me to get all the parents up to a parent with specific Id? I have a deeply nested unordered list, and if I have a reference to one of the "li" I need to find all parent "li" up to a root "ul". If I use parents() it gives me a开发者_运维技巧ll parents up to a root of document. One way would be just to write recursive function and check for id of the parent, but if there is something built in I would rather use that.
Parents Until should work for that. I think you need jQuery 1.4 to use it though.
$('li').closest('ul')
精彩评论