<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Set Text Contents of the Elements</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $(".btn-one").click(function(){ $("p").text("Happy Morning."); }); $(".btn-two").click(function(){ $("p:first").text("Have a Nice Day."); }); $(".btn-three").click(function(){ $("p.more").text("Enjoy Your Day."); }); }); </script> </head> <body> <button type="button" class="btn-one">Set All Paragraph</button> <button type="button" class="btn-two">Set First Paragraph</button> <button type="button" class="btn-three">Set Empty Paragraph</button> <p>This is a first paragraph.</p> <p>This is a second paragraph.</p> <p class="more"></p> </body> </html>