.even()
S2C Home « Filtering « .even()
Filter elements.
Description
The .even()
method is used to reduce the matched set to the even elements, starting at zero.
The .even()
method was added in jQuery 3.5
Syntax
Signature | Description |
---|---|
.even() | Reduce the matched set to the even elements, starting at zero. |
Parameters
None.
Return
A jQuery
object containing the filtered elements.
.even()
ExampleTop
Reduce the matched set to the even elements, starting at zero.
In the example we select all even 'td' elements and change the background colour to orange.
Table Row 1, Table Data 1 | Table Row 1, Table Data 2 |
Table Row 2, Table Data 1 | Table Row 2, Table Data 2 |
$(function(){
$('#btn21').on('click', function() {
$('.testtable td').even()
.css('backgroundColor', 'orange');
});
});
Related Tutorials
jQuery Intermediate Tutorials - Lesson 1 - Filtering Elements