728x90
SMALL
#jQuery
#jQuery selector :even
:even
:even is a selector that selects even indexed elements.
grammar
$( ':even' )
for example
$( 'p:even' )
Select an even index paragraph. Note that the first element index starts at 0.
example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$( document ).ready( function() {
$( 'li:even' ).css( 'color', 'red' );
} );
</script>
</head>
<body>
<ul>
<li>0. Lorem</li>
<li>1. Ipsum</li>
<li>2. Dolor</li>
<li>3. Sit</li>
</ul>
</body>
</html>
Select even indexed li elements and color them red.
728x90
LIST