Use not(":even") to select the odd elements - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:not

Description

Use not(":even") to select the odd 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").not(":even").css("color", "red");
});//from ww  w  .j  a v  a2  s  .c om
</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