How to find the closest descendants (that matches a selector) with jQuery?
<p>We can use <code>closest(selector)</code> to find the first ancestor element that matches the selector. It travels <strong>up</strong> the DOM tree until it finds a match for the selector. But what if I want to travels <strong>down</strong> the DOM tree until it finds a match for the selector? Is there any jQuery function for doing this? Or do I need to implement this using breadth-first search?</p>

<p>Give an example. For the DOM tree below,</p>

<pre><code>&lt;div id="main"&gt;
    &lt;div&gt;
        &lt;ul&gt;&lt;!-- I want to match this ul --&gt;
            &lt;li&gt;
                &lt;ul&gt;&lt;!-- but not this ul --&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
        &lt;ul&gt;&lt;!-- and match this ul --&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>how to do something like <code>$('#main').closestDescendants('ul')</code>?</p>
