我从谷歌的AdWords网站上获取数据,该网站有多个元素,相同的id
个元素.
Could you please explain why the following 3 queries doesn't result with the same answer (2)?
HTML:
<div>
<span id="a">1</span>
<span id="a">2</span>
<span>3</span>
</div>
JS:
$(function() {
var w = $("div");
console.log($("#a").length); // 1 - Why?
console.log($("body #a").length); // 2
console.log($("#a", w).length); // 2
});