Is this an even or odd element?
问题 So I saw this question a few moments ago on SO and it got me thinking. Basically the OP had something along these lines <div>a</div> <div>b</div> <div>c</div> <div>d</div> $('div').each( function() { //do something different based on whether even or odd div if ($(this) == ':even') {} //invalid markup I know! else {} }); Is there a way to tell inside the .each() whether your current element is an odd or even instance? There is the .filter method of jQuery, but it always returns true when it