if ( selector.nodeType ) { this[0] = selector; this.length = 1; this.context = selector; return this; } if ( typeof selector === "string" ) { var match = quickExpr.exec( selector ); xland ")把对象包装成jQuery对象 if ( match && (match[1] || !context) ) { if ( match[1] ){ selector = jQuery.clean( [ match[1] ], context );} else { var elem = document.getElementById( match[3] ); if ( elem && elem.id != match[3] ){ return jQuery().find( selector );} var ret = jQuery( elem || [] ); ret.context = document; ret.selector = selector; return ret; }
至此 - var obj = $(“#yourId”);
构造jQuery对象的初步工作就做完了 |