Skip to content

Attribute Class

g-bind

You can be used g-bind, or the shorthand :, with the class attribute to dynamically bind CSS classes to an element. You can bind a single class or an array of classes.

API

By the Graphane SVG API, you can use the .classList object and its methods:

  • .classList.contains( class ) - returns true if the list contains the given class, otherwise false.
  • .classList.add( class ) - adds the specified class.
  • .classList.remove( class ) - removes the specified class.
  • .classList.replace( oldClass, newClass) - replaces oldClass with newClass.
  • .classList.toggle( class ) - removes class from if it exists or adds class if it doesn't.

Released under the MIT License.