Get even selected elements - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:filter

Description

Get even selected elements

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").filter(":even").css("background-color", "yellow");
});//  w  w  w  . j a  v  a  2 s.  c  o  m
</script>
</head>
<body>

<p>this is a test (index 0).</p>
<p>test(index 1).</p>
<p>test(index 2).</p>
<p>test(index 3).</p>
<p>test(index 4).</p>
<p>test(index 5).</p>

</body>
</html>

Related Tutorials