Skip to content
Related Articles

Related Articles

How to remove all CSS classes using jQuery ?

Improve Article
Save Article
Like Article
  • Last Updated : 31 Dec, 2020

In this article, we will remove all CSS classes for an element using jQuery. To remove all CSS classes of an element, we use removeClass() method.

The removeClass() method is used to remove one or more class names from the selected element.


$(selector).removeClass(class_name, function(index, class_name))

Parameters: This function accepts two parameters as mentioned above and described below:

  • class_name: It is optional parameter which is used to specify the class name (one or more class) to remove. Multiple class name separated with space.
  • function: It is optional parameter and it returns one or more class name which need to be removed.
    1. index: This parameter is used to return index of element.
    2. current_class_name: This parameter returns the class name of selected elements.



<!DOCTYPE html>
<html lang="en">
        How to remove all CSS classes using jQuery?
        .GFG1 {
            color: green;
        .GFG2 {
            font-size: 30px;
            font-weight: bold;
    <!-- Import jQuery cdn library -->
    <script src=
        $(document).ready(function () {
            $("button").click(function () {
<body style="text-align: center;">
    <h1 style="color: green;">
        How to remove all CSS classes using jQuery?
    <p class="GFG1 GFG2">
        Computer Science Portal
    <button>Click Here!</button>


Before button Click:

After Button Click:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!