title: Getting the index of a list item with Jquery
body: <p>I'm trying to find out the index number of the last list item but the jquery I'm using keeps returning -1. This is the JS and the html that I'm using.</p>
  
  <pre><code>var index = $('#imageThumbnails li:last').index(this);
  
  &lt;div id="imageThumbnails"&gt;
     &lt;ul class="gallery_demo_unstyled"&gt;
        &lt;li class="active"&gt;&lt;img src="test-img.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img2.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img3.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img4.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img5.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img6.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
        &lt;li&gt;&lt;img src="test-img7.jpg" width="394" height="394" alt=" " /&gt;&lt;/li&gt;
      &lt;/ul&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Thanks for your help.</p>