Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery first parent containing all children

Tags:

How would I got about selecting the first parent of a set of elements that contains ALL of those elements?

For example:

<body>
 <dl>
  <dt>Items:</dt>
  <dd>
   <ul>
    <li>Item 1<div class="item-info">...</div></li>
    <li>Item 2<div class="item-info">...</div></li>
    <li>Item 3<div class="item-info">...</div></li>
   </ul>
  </dd>
 </dl>
</body>

I want something like this:

$('.item-info').commonParent();

and it would return the equivalent of:

[$('ul')]

Is there an easy way to do this with jQuery selectors? Or am I gonna have to write a plugin?