title: jquery accordion header index
body: <p>jquery accordion </p>
  
  <p>I like to get the index of the h3 within the "xaccordion".
  Just one link in the accordion will have the class "active" (can also be an id, but I made it an class)</p>
  
  <p>How do I get the index. now the element is not fount and the index is returning -1;</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div id="xaccordion"&gt;
    &lt;h3&gt;title&lt;/h3&gt;
    &lt;div&gt;
      &lt;p&gt;
        &lt;a href="#"&gt;link&lt;/a&gt;
        &lt;a class="active" href="#"&gt;link&lt;/a&gt;
      &lt;/p&gt;
    &lt;/div&gt;
    &lt;h3&gt;title&lt;/h3&gt;
    &lt;div&gt;
      &lt;p&gt;
        &lt;a href="#"&gt;link&lt;/a&gt;
        &lt;a href="#"&gt;link&lt;/a&gt;
      &lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>var active_header = $("#xaccordion a.active").closest("h3");
  var active_header_index = $("#xaccordion").index(active_header);
  
  console.log("index: " + active_header_index);
  </code></pre>