Embellishing the jQuery Slides with Fade Effects

If you saw yesterday’s post, you may have asked, why include the function that does nothing in the parameters for the calls to slideUp() and slideDown()? For yesterday’s example, there is no good reason. The functions will work with no parameters. The first parameter passed is duration. Slow is a nice speed. According to slideUp() and slideDown() documentation, the duration is 600 milliseconds.

The second parameter is a deferred callback function. When included in the parameters, this ‘complete’ function is called at the end. For example other jQuery effects can be used to embellish the animation when the slide animation is completed.

By the way, slideToggle() would accomplish yesterday’s example more efficiently. But if we want to differentiate the slideUp() and slideDown() animations, the if..else comes in handy.

Here is yesterday’s example embellished with different animations after the completion of slideUp() and slideDown(). After slideUp(), the body of the topic will fade out with fadeOut() and back in with fadeIn(). After slideDown(), the sliding text will fade out and back in:

Here is the behavior:

fade-in-fade-out

And the new version of the topic:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML tags are not allowed.

201,333 Spambots Blocked by Simple Comments