toggle method

bool toggle (
  1. String value,
  2. [bool shouldAdd]
)

Adds the class value to the element if it is not on it, removes it if it is.

If shouldAdd is true, then we always add that value to the element. If shouldAdd is false then we always remove value from the element.

If this corresponds to one element, returns true if value is present after the operation, and returns false if value is absent after the operation.

If this corresponds to many elements, null is always returned.

value must be a valid 'token' representing a single class, i.e. a non-empty string containing no whitespace. To toggle multiple classes, use toggleAll.

Implementation

bool toggle(String value, [bool shouldAdd]);