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
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.