When using $(".className")
, all elements with the class .className
are returned. How can I target a specific element by its index number to apply styling only to that element?
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<p class="para">first paragraph </p>
<p class="para">Second paragraph </p>
<p class="para">Third paragraph </p>
<script>
console.log($(".para"));
// console.log($(".para")[0].css({"color":"red"}));
</script>
</body>
</html>
Is there a way in this code to set the color of the first paragraph to red and the second paragraph to yellow?