interface Utils {
    closest(element: HTMLElement, selector: string, context?: HTMLElement): null | HTMLElement;
    css(element: HTMLElement): CSSStyleDeclaration;
    css<K>(element: HTMLElement, prop: K): CSSStyleDeclaration[K];
    css<K>(element: HTMLElement, prop: K, value: CSSStyleDeclaration[K]): void;
    find(context: HTMLElement, tagName: string, iterator?: ((value: HTMLElement, index: number) => void)): NodeListOf<HTMLElement>;
    is(element: HTMLElement, selector: string): boolean;
    off(element: HTMLElement, event: string, fn: EventListenerOrEventListenerObject): void;
    on(element: HTMLElement, event: string, fn: EventListenerOrEventListenerObject): void;
    toggleClass(element: HTMLElement, name: string, state: boolean): void;
}

Methods

  • For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • selector: string

      an element seletor.

    • Optionalcontext: HTMLElement

      a specific element's context.

    Returns null | HTMLElement

  • Get the values of all the CSS properties.

    Parameters

    • element: HTMLElement

      an HTMLElement.

    Returns CSSStyleDeclaration

  • Get the value of style properties.

    Type Parameters

    • K extends keyof CSSStyleDeclaration

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • prop: K

      a property key.

    Returns CSSStyleDeclaration[K]

  • Set one CSS property.

    Type Parameters

    • K extends keyof CSSStyleDeclaration

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • prop: K

      a property key.

    • value: CSSStyleDeclaration[K]

      a property value.

    Returns void

  • Get elements by tag name.

    Parameters

    • context: HTMLElement

      an HTMLElement.

    • tagName: string

      A tag name.

    • Optionaliterator: ((value: HTMLElement, index: number) => void)

      An iterator.

        • (value, index): void
        • Parameters

          • value: HTMLElement
          • index: number

          Returns void

    Returns NodeListOf<HTMLElement>

  • Check the current matched set of elements against a selector.

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • selector: string

      an element selector.

    Returns boolean

  • Remove an event handler function

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • event: string

      an Event context.

    • fn: EventListenerOrEventListenerObject

      a callback.

    Returns void

  • Attach an event handler function

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • event: string

      an Event context.

    • fn: EventListenerOrEventListenerObject

    Returns void

  • Add or remove one classes from each element

    Parameters

    • element: HTMLElement

      an HTMLElement.

    • name: string

      a class name.

    • state: boolean

      a class's state.

    Returns void