Total Page Preview: 000000000150
What is fadeToggle() in jQuery?
fadeToggle() in jQuery
The fadeToggle() method in jQuery is used to toggle between the fadeIn() and fadeOut() methods. It alternates between making selected elements visible and invisible by adjusting their opacity. If an element is currently visible, fadeToggle() will fade it out; if it's hidden, fadeToggle() will fade it in.
Here's an example demonstrating the use of fadeToggle():
In this example, there's a box element with the class "box," initially hidden with display: none; in the CSS. The jQuery code sets up a click event on this element. When the box is clicked, fadeToggle(1000) is called, which toggles the visibility of the box with a duration of 1000 milliseconds (1 second). After the toggle completes, an alert is shown with the message "Fade toggled!"
This is a simple example, and you can customize it based on your specific needs. The fadeToggle() method is handy for creating toggle effects between visible and hidden states without having to explicitly check the current state of the element.
Thank You
About Author
Brijesh Kumar
Database Developer
I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL
Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall
and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com