How to remove all CSS classes using jQuery?

jQueryWeb DevelopmentFront End Technology

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>
raja
Published on 17-Dec-2017 19:21:20
Advertisements