How to remove all CSS classes using jQuery? (2024)

To remove all classes, use the removeClass() method with no parameters. This will remove all of the item's classes.

Example

You can try to run the following code to remove all CSS classes using jQuery:

Live Demo

<html> <head> <title>jQuery Selector</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#button1").click(function(){ $("p").removeClass(); }); }); </script> <style> .red { color:red; } .blue { color:blue; } </style> </head> <body> <p class = "red" >This is first paragraph.</p> <p class = "blue">This is second paragraph.</p> <button id="button1">Remove</button> </body></html>
Kickstart Your Career

Get certified by completing the course

Get Started

How to remove all CSS classes using jQuery? (31)

Advertisem*nts

';adpushup.triggerAd(ad_id); });

How to remove all CSS classes using jQuery? (2024)
Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 6476

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.