Javascript examples for jQuery Method and Property:addClass
Use a jQuery method to add both the "important" and "test" class to the <p> element.
<!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").addClass("important test"); });//from w w w . j av a 2 s . c o m </script> <style> .important { font-weight: bold; font-size: xx-large; background-color: yellow; } .test { color: red; border: 5px dotted blue; } </style> </head> <body> <p>This is a paragraph.</p> </body> </html>