title: Find closest element on click with jQuery
body: <p>I trigger a function by click on a nested element. To prevent bubbling I could use <code>e.stopPropagation();</code>.</p>
  
  <p>If stop propagation, other scripts have trouble because they rely on bubbling on these elements. Is there another way around it? Some kind of if statement?</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;div class="nested-element"&gt;
    &lt;div class="nested-element"&gt;
      content
    &lt;/div&gt;
    content
  &lt;/div&gt;
  </code></pre>
  
  <p>The nesting is in real life unlimited.</p>
  
  <p><strong>jquery</strong></p>
  
  <pre><code>$('.selector').on('click', '.nested-element', function(e) {
      //e.stopPropagation();
      console.log($(this));
  });
  </code></pre>
  
  <p>The above will output the root parent first and then move closer to the closest element. I only want to get the closest element.</p>