EDIT:
oui, ils sont équivalents, voici la source
// HANDLE: $(expr, [context])
// (which is just equivalent to: $(content).find(expr)
} else
return jQuery(context).find(selector);
Pour utiliser efficacement le contexte, il doit être un HTMLElement, sinon le contexte est document
find()
est implémenté en tant que tel dans jQuery 1.3.2
find: function(selector) {
if (this.length === 1) {
var ret = this.pushStack([], "find", selector);
ret.length = 0;
jQuery.find(selector, this[0], ret);
return ret;
} else {
return this.pushStack(jQuery.unique(jQuery.map(this, function(elem){
return jQuery.find(selector, elem);
})), "find", selector);
}
}
find()
utilise le moteur de sélection Sizzle pour effectuer le travail de recherche (voir la ligne 2364 dans la source jQuery).
et pushStack
est
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function(elems, name, selector) {
// Build a new jQuery matched element set
var ret = jQuery(elems);
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
if (name === "find")
ret.selector = this.selector + (this.selector ? " " : "") + selector;
else if (name)
ret.selector = this.selector + "." + name + "(" + selector + ")";
// Return the newly-formed element set
return ret;
}
Brandon Aaron a écrit un grand article sur understanding the context in jQuery