// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
作者的解释呢很简单,一个简单的检测HTML字符串的表达式
match = rquickExpr.exec( selector );
4. 匹配的html或确保没有上下文指定为# id
if ( match && (match[1] || !context) ) {
5. match[1]存在,处理(html)−>(array),,也就是处理的是html方式
if ( match[1] ) {
6. 处理ID
复制代码
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 ) {
// Inject the element directly into the jQuery object
this.length = 1;
this[0] = elem;
}