BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

jQuery – Chaining multiple effects

Last Updated: May 7, 2019 by Chaitanya Singh | Filed Under: jQuery

In jQuery we can chain multiple effects together in a single line. For example $("p").slideDown().slideUp() this will make the paragraph appear with a slide down effect and then disappear the paragraph with a slide up effect.

In this guide, we will learn how to chain multiple jQuery effects together in a single line.

jQuery chaining example

Here we are chaining two effects together, the slideDown() effect and the slideUp() effect in a single line. This will make the paragraph appear and then disappear with a slide down and slide up effects respectively.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").slideDown(5000).css("font-size", "1.5em").slideUp(5000);
  });
});
</script>
</head>
<body>

<h2>jQuery chaning example</h2>
<p style="display:none">This example is published on beginnersbook.com. This para
will appear when you click on the Show Me! button with an increased font size.</p>
<button>Show Me!</button>
</body>
</html>

Output:
When Show Me! button is clicked and the slideDown() effect is finished but slideUp() is not yet started:
jQuery chaining
When the all the effects are finished:
jQuery chaining example

❮ PreviousNext ❯

Top Related Articles:

  1. jQuery html() method
  2. jQuery Fading Effects
  3. jQuery slideDown()
  4. jQuery slideUp()
  5. jQuery fadeTo() Method

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

jQuery Tutorial

  • jQuery Tutorial
  • jQuery Selectors
  • jQuery Events

jQuery Effects

  • jQuery Show & Hide
  • jQuery Fading
  • jQuery Sliding
  • jQuery Animate
  • jQuery stop()
  • jQuery Callback Function
  • jQuery Chaining

jQuery HTML/CSS

  • jQuery html()
  • jQuery addClass()
  • jQuery hasClass()
  • jQuery removeClass()
  • jQuery toggleClass()
  • jQuery after()
  • jQuery before()
  • jQuery append()
  • jQuery appendTo()
  • jQuery clone()
  • jQuery insertBefore()
  • jQuery insertAfter()
  • jQuery attr()
  • jQuery text()
  • jQuery val()
  • jQuery css()
  • jQuery prepend()
  • jQuery remove()
  • jQuery empty()
  • jQuery detach()

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap