Posted inJavaScript / jQuery

jQuery Remove Class From HTML Elements Example

Today, We want to share with you jquery remove class.In this post we will show you jquery add removes class onclick, hear for jquery add all class we will give you demo and example for implement.In this post, we will learn about jQuery removeClass Method with an example.

How to use removeClass() method in jQuery?

Example 1: index.html










Welcome To Pakainfo.com

Pakainfo - Web Development & Good Online education

This is Web Development & Good Online education Tutorials.

addClass and removeClass in jQuery

HTML Code

posted 20 Jan 14

Bangladesh

Story Title

Egestas eros ac risus faucibusr

CLOSE

jQuery Code

$(document).ready(function() {   
    $(".close_button").click(function (e) { 
        $("#spot1").addClass("spot");
        $("#spot1").removeClass("grown");
        e.stopPropagation();
    });  

    $(".clickable").click(function () {
        if ($(this).hasClass("spot")){
            $(this).addClass("grown");
            $(this).removeClass("spot");
        }
    });
});

CSS Code

.spot {
    background: #AAA;
}

.grown {
    background: #0A0;
}

.close_button {
    display: none;
}

.grown .close_button {
    display: inline;
}

Example 3: Usage of .removeClass()

$("button").click(() => {
    $("div").removeClass("introduction");
});

Example 4: No argument

$().removeClass()

Example 5: Space separated list as an argument

$().removeClass([className])

Removing all classes

index.html


 
    

   
 
 
   

Educative!

Space separated list as an argument


 
    

   
 
 
   

Educative!

Function as an argument


 
    

   
 
 
   

Educative!

I hope you get an idea about jQuery Get and Set CSS Classes.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype