W3cubDocs

/Dart 2

toggle method

bool toggle (String value, [ 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]);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-html/CssClassSet/toggle.html