The toggle() method is used to switch between hiding and showing elements.
If the element is visible, toggle() hides it.
If the element is hidden, toggle() shows it.
This method is very useful when creating buttons that open and close content.
Each time the button is clicked, the element switches its visibility.
You can apply animation duration to toggle effects.
Predefined speed values make animations easier to control.
toggle() Method Notes:
- Combines hide and show
- Useful for collapsible UI
- Supports animation speed
- Common in dropdown menus