Randomblue
Randomblue

Reputation: 116403

jQuery toggle both "slide" and "fade" animations at the same time

jQuery has a slideToggle, and a fadeToggle, but they don't play well together (see fiddle here):

$('div').on('click', function () {
    $('span')
        .slideToggle({duration: 'slow', queue: false})
        .fadeToggle({duration: 'slow', queue: false});
});

How can I have slide and fade toggle at the same time?

Upvotes: 6

Views: 5706

Answers (1)

Randomblue
Randomblue

Reputation: 116403

Use .animate() as follows:

$('span').animate({
  height: "toggle",
  opacity: "toggle"
});

Upvotes: 17

Related Questions