title: Trying to figure out how to use jQuery index() buried in parent elements
body: <p>I want to get the index of a group of elements (in this example, the a tags with the class myLink).  They are nested within parent elements. All my efforts thus far produce a 0 index for the first item, but a -1 index for the second. An example of the structure I'm looking at is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// GeekInTheBox - please fill this out</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="containerOne"&gt;
    &lt;ul class="listOne"&gt;
      &lt;li&gt;
        &lt;a class="myLink" href="blah"&gt;Link Text&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a class="myLink" href="moreBlah"&gt;More Link Text&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;script&gt;
      $('.myLink').on('click', function(){
          alert($(this).index($('.myLink')));
          alert($(this).index($('.containerOne .listOne a')));
          alert($(this).index($('.containerOne .listOne li a')));
          alert($(this).index($('.containerOne .listOne .myLink')));
          alert($(this).index($('.containerOne .listOne li .myLink')));
          alert($(this).index($('.containerOne .listOne a.myLink')));
          alert($(this).index($('.containerOne .listOne li a.myLink')));
          alert($(this).index());
          return false;
      })
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>