title: Get the parent HTML element of certain type with JS
body: <p>My code looks like this, in closeup:</p>
  
  <pre><code>&lt;h2&gt;
  &lt;span class="stuff"&gt;[&lt;a id="someid"&gt;stuff&lt;/a&gt;]&lt;/span&gt; &lt;span class="moreStuff"&gt;Another test&lt;/span&gt;
  &lt;/h2&gt;
  </code></pre>
  
  <p>I've found a way to select my <code>a</code> element, and attach an id to it. What I need to do now is select its parent <code>&lt;h2&gt;</code> element, but not the <code>&lt;span&gt;</code> element. How can I do that (JQuery allowed)?</p>
  
  <p>Edit: when I retrieve the selected <code>&lt;a&gt;</code>s, I get an array of them (there's lots of these structures on my page). When I try to write <code>myArray[someIndex].closest("h2")</code>, it says that the element does not have a <code>closest()</code> method. How would I go about this?</p>