jquery

Remove class from element jQuery

$("div").removeClass("hello");

//REMOVE CLASS ON BUTTON CLICK
$("button").click(function() {
    $(".elem").removeClass("dark_theme");
});

.removeClass() method in jQuery is used to remove a CSS class from an HTML element using its name. In the code snippet, we are removing a class named hello from the div element.

If there is no class added on the div element it will do nothing. In the second code snippet example, we are removing class by its name from an element which has a class named 'elem' on button click.

Was this helpful?