The example in this article describes how jQuery uses the addClass() method to add multiple class styles to elements. Share it with everyone for your reference. The details are as follows:
jQuery adds multiple classes to elements through the addClass() method. You only need to separate multiple classes with spaces in the added classes
<!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").addClass("important blue"); }); }); </script> <style type="text/css"> .important { font-weight:bold; font-size:xx-large; } .blue { color:blue; } </style> </head> <body> <div id="div1">This is some text.</div> <div id="div2">This is some text.</div> <br> <button>Add classes to first div element</button> </body> </html>
I hope this article will be helpful to everyone’s jQuery programming.