title: Jquery index doesn't work for child nodes
body: <p>I would like to index everything in document and then call it by its index. The HTML:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li id="foo"&gt;foo&lt;/li&gt;
    &lt;li id="bar"&gt;bar&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Alert to get index:</p>
  
  <pre><code>alert('Index: ' + $('#foo').index());
  </code></pre>
  
  <p>The problem is that it alerts number <code>0</code> for both <code>ul</code> and <code>#foo</code>. I understand the logic of this but I need them in order, so the <code>ul</code> should count for <code>0</code> and <code>#foo</code> should be <code>1</code>.</p>
  
  <p>What can I try to get this type of indexing? I tried <code>prevAll()</code> but that gives the same result.</p>
  
  <p>PS Please not this is just an example, in reality the code should work on large documents. </p>
  
  <p><a href="http://jsfiddle.net/p83Rg/12/" rel="nofollow">Example code</a></p>