Skip to content

Commit f454097

Browse files
committed
Core: Implement .even() & .odd() to replace POS :even & :odd
1 parent 29a9544 commit f454097

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ jQuery.fn = jQuery.prototype = {
100100
return this.eq( -1 );
101101
},
102102

103+
even: function() {
104+
return this.filter( function( i ) {
105+
return ( i + 1 ) % 2;
106+
} );
107+
},
108+
109+
odd: function() {
110+
return this.filter( function( i ) {
111+
return i % 2;
112+
} );
113+
},
114+
103115
eq: function( i ) {
104116
var len = this.length,
105117
j = +i + ( i < 0 ? len : 0 );

0 commit comments

Comments
 (0)