Function: toggle()
Overload 1
toggle(
element):void
Defined in: dom.ts:294
Toggles the visibility of the given element: hides it if visible, shows it if hidden.
Parameters
element
HTMLElement
The target element.
Returns
void
Example
ts
// HTML
<p id="message">Hello!</p>
// JS
const el = facile.getElement('#message');
facile.toggle(el); // hides it
facile.toggle(el); // shows itOverload 2
toggle<
K>(tag):void
Defined in: dom.ts:306
Toggles the visibility of the first element matching the given tag name. Does nothing if no element is found.
Type Parameters
K
K extends keyof HTMLElementTagNameMap
Parameters
tag
K
The HTML tag name to search for.
Returns
void
Example
ts
// HTML
<p>Hello!</p>
// JS
facile.toggle('p'); // hides it
facile.toggle('p'); // shows itOverload 3
toggle(
selector):void
Defined in: dom.ts:318
Toggles the visibility of the first element matching the given CSS selector. Does nothing if no element is found.
Parameters
selector
string
A CSS selector string.
Returns
void
Example
ts
// HTML
<p id="message">Hello!</p>
// JS
facile.toggle('#message'); // hides it
facile.toggle('#message'); // shows it