Make .add() take an optional context and - if a context is specified in the root selector - use that as the base context.

This commit is contained in:
John Resig 2009-11-07 16:43:31 +01:00
parent ef05f44cce
commit b0fe380cf8
2 changed files with 15 additions and 3 deletions

View file

@ -68,9 +68,9 @@ jQuery.fn.extend({
});
},
add: function( selector ) {
add: function( selector, context ) {
var set = typeof selector === "string" ?
jQuery( selector ) :
jQuery( selector, context || this.context ) :
jQuery.makeArray( selector ),
all = jQuery.merge( this.get(), set );
@ -185,4 +185,4 @@ jQuery.extend({
return r;
}
});
});