Add a red color to all <p> elements with class="intro". - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Add a red color to all <p> elements with class="intro".

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(".intro").css("color", "red");
});//from   w w w.j av a2 s . c om
</script>
</head>
<body>

<p>First paragraph.</p>
<p class="intro">Second paragraph.</p>
<p class="intro">Third paragraph.</p>
<p>Last paragraph.</p>

</body>
</html>

Related Tutorials