jQuery toggle() Method (original) (raw)

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.

Syntax:

$(selector).toggle(speed, easing, callback)

Parameters: It has three optional parameters:

Below is the example to show the toggle() method:

html `

<div id="gfg">GeeksforGeeks</div>

<button>Click to hide() and show() the above div</button>

`

**Output:**Before clicking on the button:After clicking on the button:After clicking on the button again: