diff options
author | John Resig <jeresig@gmail.com> | 2009-09-09 00:21:21 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-09-09 00:21:21 +0000 |
commit | 9de120e6d7cfffa3d990a6ccf23db3cd74e2bdc0 (patch) | |
tree | 0b8131825b85c22167b141e8ae20079d90ba034c /src/traversing.js | |
parent | 4ea4fad0902839c06c281b5de7b0aca29922b63d (diff) | |
download | jquery-9de120e6d7cfffa3d990a6ccf23db3cd74e2bdc0.tar.gz jquery-9de120e6d7cfffa3d990a6ccf23db3cd74e2bdc0.zip |
Added support for .eq(-N), .first(), and .last(). Fixes #2164 and #4188.
Diffstat (limited to 'src/traversing.js')
-rw-r--r-- | src/traversing.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/traversing.js b/src/traversing.js index f46820f84..1342c5959 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -78,7 +78,17 @@ jQuery.fn.extend({ }, 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() { |