Skip to content

HTMLElement.toggle method

HTMLElement › toggle

Official

Toggles the visibility of the element using css display property.

Signature:

toggle(show: boolean): void

Parameters:

Parameter Type Description
show boolean Whether to show the element.

Returns: void

Example:

document.body.toggle(true);
document.body.toggle(false);