:odd
selectorThe :odd selector get the odd element from the matched set.The index is based on 0. So the matched elements would have index like 1,3,5,7 etc.
:odd
selector syntax$(':odd')
In below example,We will implement a striped table using jQuery.
<table> <thead> <tr><th>Col Header</th><th>Col Header</th></tr> </thead> <tbody> <tr><td>Row1 Col1</td><td>Row1 Col2</td></tr> <tr><td>Row2 Col1</td><td>Row2 Col2</td></tr> <tr><td>Row3 Col1</td><td>Row3 Col2</td></tr> <tr><td>Row4 Col1</td><td>Row4 Col2</td></tr> <tr><td>Row5 Col1</td><td>Row5 Col2</td></tr> </tbody> </table> <script> $('tr:odd').css('background-color','grey'); </script>