jQuery Selectors: Filters out all odd indexed elements

This entry is part 27 of 33 in the series jQuery Selectors


An example would be $(‘tr:even’) where it will select the first, third and so on as the first item starts with index 0.

<!doctype html>
<html lang='en'>
    <meta charset='utf-8'>
    <title>even demo</title>
        table {
            background: #eee;
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>

<table border='1'>
        <td>Row with Index #0</td>
        <td>Row with Index #1</td>
        <td>Row with Index #2</td>
        <td>Row with Index #3</td>

    $('tr:even').css('background-color', '#bbf');



Series Navigation<< jQuery Selectors: Selects visible elements
jQuery Selectors: Filter out everything but the first element >>

Leave a comment

Leave a Reply