Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

jQuery fadeToggle()

jQuery fadeToggle() method is used to toggle between the fadeIn() and fadeOut() methods. If the elements are faded in, it will make them faded out and if they are faded out it will make them faded in.


  1. $(selector).fadeToggle();
  2. $(selector).fadeToggle(speed,callback);
  3. $(selector).fadeToggle(speed, easing, callback);

speed: It is an optional parameter. It specifies the speed of the delay. Its possible vales are slow, fast and milliseconds.

easing: It specifies the easing function to be used for transition.

callback: It is also an optional parameter. It specifies the function to be called after completion of fadeToggle() effect.

Let’s take an example to demonstrate jQuery fadeToggle() effect.

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src=“”></script>
  5. <script>
  6. $(document).ready(function(){
  7.     $(“button”).click(function(){
  8.         $(“#div1”).fadeToggle();
  9.         $(“#div2”).fadeToggle(“slow”);
  10.         $(“#div3”).fadeToggle(3000);
  11.     });
  12. });
  13. </script>
  14. </head>
  15. <body>
  16. <p>See the fadeToggle() method example with different parameters.</p>
  17. <button>Click to fade Toggle boxes</button><br><br>
  18. <div id=“div1” style=“width:80px;height:80px;background-color:red;”></div><br>
  19. <div id=“div2” style=“width:80px;height:80px;background-color:green;”></div><br>
  20. <div id=“div3” style=“width:80px;height:80px;background-color:blue;”></div>
  21. </body>
  22. </html>

Test it Now


See the fadeToggle() method example with different parameters.