Added .eq(Number) back in - I'm convinced that it's more useful than the .slice() replacement. lt/gt are still gone, though.

This commit is contained in:
John Resig 2007-09-15 03:08:46 +00:00
parent 1088d06e54
commit 3dabd7ec30
2 changed files with 7 additions and 1 deletions

View file

@ -363,6 +363,10 @@ jQuery.fn = jQuery.prototype = {
return this.after( val ).remove(); return this.after( val ).remove();
}, },
eq: function(i){
return this.slice(i, i+1);
},
slice: function() { slice: function() {
return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
}, },

View file

@ -1034,11 +1034,13 @@ test("empty()", function() {
}); });
test("slice()", function() { test("slice()", function() {
expect(4); expect(5);
isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" ); isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" ); isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" ); isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" ); isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );
}); });
test("map()", function() { test("map()", function() {