Javascript examples for jQuery:Selector
Add a red color to all <p> elements with class="intro".
<!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>