.eq( index ) 参数是可取负值,若非负则为对象索引。
1. eq: function( i ) {
2. return i === -1
3. this.slice( i ) :
4. this.slice( i, +i + 1 );
5. }
例子:
1.
- list item 1
- list item 2
- list item 3
- list item 4
- list item 5
2.
3.
4.
5.
6.
7.
而first()和last()都是内部调用的eq():
1. first: function() {
2. return this.eq( 0 );
3. },
4.
5. last: function() {
6. return this.eq( -1 );
7. }
关于jQuery.slice参见slice篇。