How to remove all CSS classes using jQuery?


To remove all CSS classes using jQuery, use the removeClass() method, with no argument.

Example

You can try to run the following code to remove class:

Live Demo

<html>

   <head>
      <title>jQuery Example</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
   
      <script>
         $(document).ready(function() {
            $("p").removeClass();
         });
      </script>
       
      <style>
         .red {
            color:red;
         }
         .green {
            color:green;
         }
      </style>
   </head>
   
   <body>
      <p class = "red" >This is first paragraph.</p>
      <p class = "green">This is second paragraph.</p>
   </body>
   
</html>

Updated on: 17-Dec-2019

411 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements