Utility Classes

ES6

Utility classes can help you perform common tasks more easily.

Explanation

  • hasClass(elm, classN): Checks if an element has a specific class.
  • getCssProperty(elm, prop): Gets the computed value of a CSS property for an element.

Usage

To use these utility classes, you can call the static methods on the SuperTools class:

class SuperTools {
  static hasClass(elm, classN) {
    return new RegExp('(\\s|^)' + classN + '(\\s|$)').test(elm.classN);
  }
  static getCssProperty(elm, prop) {
    return window.getComputedStyle(elm, null).getPropertyValue(prop);
  }
}
SuperTools.hasClass(elm, 'class-name');