// HANDLE: $(#id)
} else {
elem = document.getElementById( match[2] );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[2] ) {
return rootjQuery.find( selector );
}
// Otherwise, we inject the element directly into the jQuery object
this.length = 1;
this[0] = elem;
}
this.context = document;
this.selector = selector;
return this;
你看看JQ中ID选择器的源码~~注意里面的this.length = 1;这一行~~~在源码文件的152行,你试试把源码文件中这个数值改一下就明白了,另外如果是多个相同的ID,应该使用class类选择器,ID的存在就是要保证不相同的~~ |