Why Isn't the jQuery .index() function behaving like I expect here?
<p>I am having issues understanding why my jQuery index() function is not performing the way I expect it to. Perhaps I'm not understanding this. Let me show you.</p>

<p>I set up a new array. We'll use this later:</p>

<pre><code>var mySources = new Array(); 
</code></pre>

<p>I have 5 images on my page:</p>

<pre><code>&lt;div id="homeSlides"&gt;
       &lt;img src="../images/homeImages/00.jpg" width="749" height="240" alt="myAltTag" /&gt;
       &lt;img src="../images/homeImages/01.jpg" width="749" height="240" alt="myAltTag"  /&gt;
       &lt;img src="../images/homeImages/02.jpg" width="749" height="240" alt="myAltTag" /&gt;
       &lt;img src="../images/homeImages/03.jpg" width="749" height="240" alt="myAltTag" /&gt;
       &lt;img src="../images/homeImages/04.jpg" width="749" height="240" alt="myAltTag" /&gt;
</code></pre>

<p></p>

<p>I put them all in an jQuery object, like this:</p>

<pre><code>var myImages = $("#homeSlides img");
</code></pre>

<p>Now, for each one, I extract the src attribute and push  it into the mySources array like this:</p>

<pre><code> $(myImages).each( function(index) {
        mySources[index] = $(this).attr('src');
});
</code></pre>

<p>Now, I will run the array to the FireBug console to make sure it worked.</p>

<p>This...</p>

<pre><code>console.log(mySources);
</code></pre>

<p>...returns this...</p>

<pre><code>["../images/homeImages/00.jpg", "../images/homeImages/01.jpg", "../images/homeImages/02.jpg", "../images/homeImages/03.jpg", "../images/homeImages/04.jpg"]
</code></pre>

<p>...which is what I expect.</p>

<p>Now I do this:</p>

<pre><code>var myVar = $(myImages).eq(2).attr('src');
</code></pre>

<p>Tracing that variable now...</p>

<pre><code>console.log(myVar);
</code></pre>

<p>...returns this...</p>

<pre><code>../images/homeImages/02.jpg
</code></pre>

<p>But then when I do this...</p>

<pre><code>console.log('Index of ' + myVar + " is: " + ($(myVar).index( mySources )) );
</code></pre>

<p>...it returns this:</p>

<pre><code> Index of ../images/homeImages/02.jpg is: -1
</code></pre>

<p>This is throwing me. Why would it return -1 for "not found" when it should be retunring 2. It does mat the second slot in the mySources array, no?</p>
