HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

toggle

Description

The toggle of DOMTokenList for JS if force is not given, "toggles" token, removing it if it’s present and adding it if it’s not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()).

Returns true if token is now present; otherwise false.

Throws a "SyntaxError" DOMException if token is empty.

Throws an "InvalidCharacterError" DOMException if token contains any spaces.

Syntax

tokenlist.toggle(token [, force])

Parameters

token

A string.

force

A boolean.

Examples

1 · token · remove

2 · token · add

3 · force · false

4 · force · true

5 · return · false

6 · return · true