VOOZH about

URL: https://www.geeksforgeeks.org/jquery/jquery-toggle-method/

⇱ jQuery toggle() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

jQuery toggle() Method

Last Updated : 30 Jun, 2023
The toggle() method is used to check the visibility of selected elements to toggle between hide() and show() for the selected elements.
  • show() is run when the element is hidden.
  • hide() is run when the element is visible.
Syntax:
$(selector).toggle(speed, easing, callback)
Parameters: It has three optional parameters:
  • speed: It is used to specify the speed of the toggle effect. It can be in terms of milliseconds, slow or fast.
  • easing: It is used to specify the speed of the element at the different points of animation.
  • callback: The function to be immediately called after the toggle effect.
Below is the example to show the toggle() method: Output: Before clicking on the button: 👁 Image
After clicking on the button: 👁 Image
After clicking on the button again: 👁 Image
Comment
Article Tags:

Explore