Get closest element by traversing DOM backwards
<p>I want to get a DOM element with jQuery but i want to only look backwards in the DOM.</p>

<p>So suppose i have the following HTML structure:</p>

<pre><code>&lt;div id="content"&gt;
    &lt;div id="first-module" class="module"&gt;
        &lt;h3&gt;Some Module&lt;/h3&gt;
        &lt;p&gt;Lorem ipsum... &lt;/p&gt;

        &lt;div id="some-other-content"&gt;
            &lt;div id="second-module" class="module"&gt;
                &lt;h3&gt;Some other module&lt;/h3&gt;
                &lt;p&gt;Dolor sit amet...&lt;/p&gt;
                &lt;button class="trigger"&gt;Trigger 1&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;

        &lt;button class="trigger"&gt;Trigger 2&lt;/button&gt;
        &lt;div id="third-module" class="module"&gt;
            &lt;h3&gt;Another module&lt;/h3&gt;
        &lt;/div&gt;
    &lt;div&gt;
&lt;/div&gt;

$('.trigger').click(function() {
    // Traverse DOM to find closest .module class
});
</code></pre>

<p>So when i click on the <code>Trigger 1</code> button i want it to find the <code>div</code> with ID <code>second-module</code>.</p>

<p>When i click on <code>Trigger 2</code> i want it to find the <code>div</code> with ID <code>first-module</code> and <strong>not</strong> <code>second-module</code>, because it's nested deeper than the <code>Trigger 2</code> button is.</p>

<p>Is there a jQuery function for this?</p>
