jQuery | :even Selector
The jQuery :even selector used to select an even number index from the elements. The number of index starts from 0. The working is same as :odd selectors but for even numbers.
syntax
$(":even")
Example-1:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("tr:even").css("background-color", "green"); }); </script> </head> <body> <center> <h1>GeeksForGeeks</h1> <table border="1"> <tr> <th>Company</th> <th>Country</th> </tr> <tr> <td>reliance</td> <td>India</td> </tr> <tr> <td>flipkart</td> <td>India</td> </tr> <tr> <td>walmart</td> <td>American</td> </tr> <tr> <td>Ernst Handel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>UK</td> </tr> </table> </center> </body> </html> |
chevron_right
filter_none
Output:

Example-2:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("tr:even").css("background-color", "lightgreen"); }); </script> </head> <body> <center> <h1>Welcome To GeeksForGeeks </h1> <table border="2"> <tr> <th>State</th> <th>Capital</th> </tr> <tr> <td>uttar pradesh</td> <td>lucknow</td> </tr> <tr> <td>punjab</td> <td>chandigarh</td> </tr> <tr> <td>haryana</td> <td>candigarh</td> </tr> </table> </center> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | #id Selector
- jQuery | :not() Selector
- jQuery | :lt() Selector
- jQuery | :has() Selector with example
- jQuery | :contains() Selector
- jQuery | :first Selector
- jQuery | :gt() Selector
- jQuery | :odd Selector
- jQuery | * Selector
- jQuery | :last Selector
- Not class selector in jQuery
- jQuery | :nth-last-child() Selector
- jQuery | :only-of-type Selector
- jQuery | :parent Selector
- jQuery | [attribute^=value] Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



