return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector );
},
- closest: function( selector ) {
+ closest: function( selector, context ) {
var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null,
closer = 0;
return this.map(function(){
var cur = this;
- while ( cur && cur.ownerDocument ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
jQuery.data(cur, "closest", closer);
return cur;
},
eq: function( i ) {
- return this.slice( i, +i + 1 );
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
},
slice: function() {
return this.pushStack( jQuery.unique( ret ), name, selector );
};
-});
\ No newline at end of file
+});