jQuery DOM Reference

jQuery removeClass() Method

jQuery removeClass() method is used to remove specific CSS class and it's styles from the set of matched elements.

Syntax
.removeClass(className)
If a class name is mentioned as a parameter, then the particular class will be removed from the group of matched elements. If no class names are specified in the parameter, all classes will be deleted.

HTML
<h1>If you click on the below button, it will remove the <font color="blue">blue</font> color style from the paragraphs</h1>

<p class="badClass">I am styled with badClass</p>

<p class="badClass">If you remove badClass from me, I won't have style anymore!!!!.</p>

<button>Remove the "badClass" from all p elements</button>

jQuery

$(document).ready(function(){
$("button").click(function(){
$("p").removeClass("badClass");
});
});

In the above HTML code, we have styled the two paragraph elements with a blue color text. Using the jquery removeClass() method we can simply remove those style by targeting the two css classes badClass. 

Comments