Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 962
Randomblue Avatar asked Feb 09 '13 15:02

Randomblue


People also ask

How do you toggle slideUp and slideDown in jQuery?

The slideToggle() method toggles between slideUp() and slideDown() for the selected elements. This method checks the selected elements for visibility. slideDown() is run if an element is hidden. slideUp() is run if an element is visible - This creates a toggle effect.

How do I fade toggle in jQuery?

jQuery fadeToggle() Method If the elements are faded out, fadeToggle() will fade them in. If the elements are faded in, fadeToggle() will fade them out. Syntax: $(selector).fadeToggle(speed,callback);

How do you create a left and right toggle effect in jQuery slide?

The task here is to create a slide left and right toggle effect in the JQuery, you can use the jQuery animate() method. . animate() method: It is used to change the CSS property to create the animated effect for the selected element.

How to toggle show and hide in jQuery?

The toggle() method toggles between hide() and show() for the selected elements. This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.


1 Answers

Use .animate() as follows:

$('span').animate({
  height: "toggle",
  opacity: "toggle"
});
like image 127
Randomblue Avatar answered Sep 19 '22 23:09

Randomblue