Javascript examples for jQuery Method and Property:removeClass
The removeClass() method removes one or more class names from the selected elements.
$(selector).removeClass(classname,function(index,currentclass));
Parameter | Require | Description |
---|---|---|
classname | Optional. | one or more class names to remove. |
function(index,currentclass) | Optional. | A function that returns one or more class names to remove |
To remove several classes, separate the class names with space
If classname parameter is empty, all class names will be removed
The following code shows how to Remove the class name "intro" from all <p> elements:
<!DOCTYPE html> <html> <head> <style> .intro {/*from w ww.j a v a 2 s. c o m*/ font-size: 120%; color: blue; background-color:#EEE; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").removeClass("intro"); }); }); </script> </head> <body> <h1>This is a heading</h1> <p class="intro">This is a paragraph.</p> <p class="intro">This is another paragraph.</p> <button>test</button> </body> </html>