user4668844
user4668844

Reputation:

Remove class, then hide element

I have the following:

$("body").removeClass("open", function()
{
    $(".sidebar").hide();
});

It removes the class from the body, but it doesn't hide the sidebar and I'm not sure why. The class names are definitely correct.

I need the sidebar to be hidden after the animation of removing class .open is done.

Upvotes: 0

Views: 92

Answers (2)

Katana314
Katana314

Reputation: 8610

removeClass only takes one argument; It's immediate, not asynchronous, so you can just run this.

$("body").removeClass("open");
$(".sidebar").hide();

Upvotes: 3

Ry-
Ry-

Reputation: 224886

Why are you passing a callback to removeClass? It doesn’t accept one.

$("body").removeClass("open");
$(".sidebar").hide();

Upvotes: 2

Related Questions