How jQuery works when there are multiple elements with the same "id"?
<p>I fetch data from Google's AdWords website which has multiple elements with the same <code>id</code>.</p>

<p>Could you please explain why the following 3 queries doesn't result with the same answer (2)?</p>

<p><a href="http://jsfiddle.net/P2j3f/1/" rel="nofollow">Live Demo</a></p>

<p>HTML:</p>

<pre><code>&lt;div&gt;
    &lt;span id="a"&gt;1&lt;/span&gt;
    &lt;span id="a"&gt;2&lt;/span&gt;
    &lt;span&gt;3&lt;/span&gt;
&lt;/div&gt;
</code></pre>

<p>JS:</p>

<pre><code>$(function() {
    var w = $("div");
    console.log($("#a").length);            // 1 - Why?
    console.log($("body #a").length);       // 2
    console.log($("#a", w).length);         // 2
});
</code></pre>
