<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adding a Class to the Elements in jQuery</title> <style> .page-header{ color: orange; text-transform: uppercase; } .highlight{ background: blue; } .hint{ font-style: blod; } </style> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("h1").addClass("page-header"); $("p.hint").addClass("highlight"); }); }); </script> </head> <body> <h1>jQuery addClass() Method</h1> <p>With the jQuery addClass() method, it becomes possible to append one or more classes to the chosen elements.</p> <p class="hint"><strong>Tip:</strong> Jquery addclass dummy text.</p> <button type="button">Add Class</button> </body> </html>