What is the purpose of fadeToggle() method in JQuery ?
In this article, we will see how to create a fadeToggle effect using jQuery. The fadeToggle effect can be created using fadeToggle() method.
The fadeToggle() method is used to toggle between the fadeIn() and fadeOut() methods. If elements are faded in, fadeToggle() will fade out. If elements are faded out, fadeToggle() will fade in.
$(selector).fadeToggle(speed, easing, callback)
In the below example, first we create a div of size 250px X 200px and set its display property to none. Also, created a button that calls fadeToggle() method. When the user clicks on the button, the fadeToggle() method is called and the div element will display and if again the same button is clicked, the div element will disappear.