title: jquery selector closest, unable to get it
body: <p>I have a html like below. I want to select the h3 closest to the span having text laptop</p>
  
  <pre><code>.
  .
  .
  .
  .
  &lt;div&gt;
  &lt;div&gt;
      &lt;h3&gt;
      &lt;a href="https://example2.com"&gt;test1&lt;/a&gt;
      &lt;/h3&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
      &lt;h3&gt;
      &lt;a href="https://example1.com"&gt;test3&lt;/a&gt;
      &lt;/h3&gt;
      &lt;div&gt;
          &lt;div&gt;&lt;/div&gt;
          &lt;span&gt;......laptop is need .......&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
      &lt;h3&gt;
      &lt;a href="https://example3.com"&gt;test3&lt;/a&gt;
      &lt;/h3&gt;
      &lt;span&gt;......laptop in .......&lt;/span&gt;
  &lt;/div&gt;
  .
  .
  .
  </code></pre>
  
  <p>I am trying to select all the <code>h3</code> that are closest to the <code>span</code> having text <code>laptop</code></p>
  
  <p>I tried</p>
  
  <pre><code>$("span:contains('laptop')").closest("h3")
  </code></pre>