Explain slide toggle method in jQuery
The slideToggle() is a method in jQuery which is an alternative for two separate methods namely slideUp() and slideDown().
This actually plays with the CSS display property of the element and provides a slight animation to it. If the element has a “display:none“, the slideDown() functionality gets toggled, and if the display is set to any other property, slideUp() comes into the picture.
Parameters: Multiple parameters can be passed to the function such as speed of the animation, the type of easing property (swing & linear), and the callback function.
- speed: The default value of the speed parameter is 400 milliseconds. This is an optional parameter. Other options are “fast” and “slow”.
- ease_property: The default property is “swing” and “linear”. This is also an optional parameter.
- callback_function: This has to be defined by the user and this is also an optional parameter.
Example 1: The following example demonstrates the slideToggle() method.
Example 2: The following example code demonstrates the usage of parameters in the slideToggle() method.
This is how the slideToggle() function works and these are generally useful for normal working websites. This function is not very useful if we want to create an aesthetic as the animation is not very smooth.
Please Login to comment...