Edit this page

up.element up.element.toggleClass(element, className, [newPresent])
JavaScript function

This feature has been deprecated. Use Element#classList.toggle(className) instead.

Load unpoly-migrate.js to polyfill deprecated features.

Adds or removes the given class from the given element.


Parameters

element Element

The element for which to add or remove the class.

className string

The class which should be added or removed.

[newPresent] Boolean optional

Pass true to add the class to the element or false to remove it.

If omitted, the class will be added if missing and removed if present.