: Even is the jQuery selector that selects the first, third, fifth (and so on) element of a page that is of the same type or that have the same class.
Example of what you get using the jQuery: even selector
Line 1
Line 2
Line 3
Line 4
Line 5
Step 1
You need to specify elements that are the same type or that have the same class.
<div class="line">Line 1</div>
<div class="line">Line 2</div>
<div class="line">Line 3</div>
<div class="line">Line 4</div>
<div class="line">Line 5</div>
<button>Click me</button>
Finally, the following jquery indicates that when the button is clicked, the first, third, and fifth lines will get a background color.
$('button').click(function(){
	$('.line:even').css('background-color', '#bbbbff');
});
| Row 1 | 
| Row 2 | 
| Row 3 | 
| Row 4 | 
| Row 5 | 
<table border="1">
	<tr><td>Row 1</td></tr>
	<tr><td>Row 2</td></tr>
	<tr><td>Row 3</td></tr>
	<tr><td>Row 4</td></tr>
	<tr><td>Row 5</td></tr>
</table>
<script>
$('tr:even').css('background-color', '#bbbbff');
</script>
 
 
 
 
 
 
 
 
 Posts
Posts
 
 
 


 
 
Post A Comment:
0 comments: