hmahdavi
hmahdavi

Reputation: 2354

Why don't play animation when run toggleClass?

I use this code for toggleClass the show and hide class .This worked but not true .In this case 1 second wait and then run toggleclass with out animation.

$(function () {
    $("#open_search").click(function () {
        $("#search").toggleClass("show",1000);
        $("#open_search").toggleClass("hide",1000);
    });
});

Upvotes: 0

Views: 58

Answers (2)

Shrikantha Budya
Shrikantha Budya

Reputation: 644

I suggest you use toggle() instead of toggleClass() if you are just looking forward to hide or show the element,But if you are thinking of creating many elements with "show" or "hide" classes you will need to add additional css code to just hide the elements...so toggle() is better

Upvotes: 0

Thomas Landauer
Thomas Landauer

Reputation: 8355

My guess: You don't want toggleClass(), but rather toggle(). Try:

$("#search").toggle();

Upvotes: 2

Related Questions