Use jQuery's toggle () method to display and hide HTML tags.
This is an example:
<Html>
The toggle () method used in the example:
The toggle () method switches the visible state of the element. If the selected elements are visible, these elements are hidden. If the selected elements are hidden, these elements are displayed. Syntax $ (selector). toggle (speed, callback, switch)
Parameters |
Description |
Speed |
Optional. Specifies the speed (or opposite) of the element from visible to hidden ). The default value is "0 ". Possible values:
- Millisecond (e.g. 1500)
- "Slow"
- "Normal"
- "Fast"
When you set the speed, the height, width, margin, padding, and transparency of an element gradually change from visible to hidden. If this parameter is set, the switch Parameter cannot be used. |
Callback |
Optional. The function to be executed after the toggle function is executed. To learn more about callback, visit our jQuery Callback chapter. This parameter cannot be set unless the speed parameter is set. |
Switch |
Optional. Boolean value. Specifies whether toggle hides or displays all selected elements.
- True-show all elements
- False-hide all elements
If this parameter is set, the speed and callback parameters cannot be used. |
PS: This effect applies to elements hidden by jQuery, or elements declared with display: none in CSS (but not visibility: hidden ).