Add a red color to third <p> element. - Javascript jQuery

Javascript examples for jQuery:Tag Traversing

Description

Add a red color to third <p> element.

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").eq(2).css("color", "red");
});//from  w w w.  ja va  2 s . c  om
</script>
</head>
<body>

<p>First paragraph.</p>
<p>Second paragraph.</p>
<p>Third paragraph.</p>
<p>Last paragraph.</p>

</body>
</html>

Related Tutorials