Class default

Constructors

  • Create a new instance of the HTML class.

    Parameters

    • elm: string | HTMLElement

      The HTML element to be created or classified from.

    Returns default

Properties

elm: HTMLInputElement | HTMLElement

The HTML element referenced in this instance. Change using .swapRef(), or remove using .cleanup().

Methods

  • Append an element. Typically used as a .append(new HTML(...)) call.

    Parameters

    • elem: string | default | HTMLElement

      The element to append.

    Returns default

    HTML

  • Append multiple elements. Typically used as a .appendMany(new HTML(...), new HTML(...) call.

    Parameters

    • Rest ...elements: any[]

      The elements to append.

    Returns default

    HTML

  • Append this element to another element. Uses appendChild() on the parent.

    Parameters

    • parent: string | default | HTMLElement

      Element to append to. HTMLElement, HTML, and string (as querySelector) are supported.

    Returns default

    HTML

  • Set attributes (object method.)

    Parameters

    • obj: {
          [x: string]: any;
      }

      The attributes to set (as an object of key: value;)

      • [x: string]: any

    Returns default

    HTML

  • Toggle on/off a class.

    Parameters

    • Rest ...val: string[]

      The class to toggle.

    Returns default

    HTML

  • Toggles OFF a class.

    Parameters

    • Rest ...val: string[]

      The class to disable.

    Returns default

    HTML

  • Toggles ON a class.

    Parameters

    • Rest ...val: string[]

      The class to enable.

    Returns default

    HTML

  • Safely remove the element. Can be used in combination with a .swapRef() to achieve a "delete & swap" result.

    Returns default

    HTML

  • Clear the innerHTML of the element.

    Returns default

    HTML

  • Retrieve HTML content from the element.

    Returns string

    string

  • Retrieve text content from the element. (as innerText, not trimmed)

    Returns string

    string

  • Retrieve the value of the element. Only applicable if it is an input or textarea.

    Returns string

    string

  • Sets the text of the current element.

    Parameters

    • val: string

      The text to set to.

    Returns default

    HTML

  • Sets the ID of the element.

    Parameters

    • val: string

      The ID to set.

    Returns default

    HTML

  • Apply an event listener.

    Parameters

    • ev: string

      The event listener type to add.

    • cb: EventListenerOrEventListenerObject

      The event listener callback to add.

    Returns default

    HTML

  • Prepend an element. Typically used as a .prepend(new HTML(...)) call.

    Parameters

    • elem: string | default | HTMLElement

      The element to prepend.

    Returns default

    HTML

  • Prepend multiple elements. Typically used as a .prependMany(new HTML(...), new HTML(...) call.

    Parameters

    • Rest ...elements: any[]

      The elements to prepend.

    Returns default

    HTML

  • An easier querySelector method.

    Parameters

    • query: string

      The string to query

    Returns null | default

    a new HTML

  • An easier querySelectorAll method.

    Parameters

    • query: string

      The string to query

    Returns null | (null | default)[]

    a new HTML

  • querySelector something.

    Parameters

    • selector: string

      The query selector.

    Returns null | HTMLElement

    The HTML element (not as HTML)

  • Apply CSS styles (dashed method.) Keys use CSS syntax, e.g. background-color.

    Parameters

    • obj: {
          [x: string]: string | null;
      }

      The styles to apply (as an object of key: value;.)

      • [x: string]: string | null

    Returns default

    HTML

  • Apply CSS styles (JS method.) Keys use JS syntax, e.g. backgroundColor.

    Parameters

    • obj: {
          [key: string]: string | null;
      }

      The styles to apply (as an object of key: value;)

      • [key: string]: string | null

    Returns default

    HTML

  • Swap the local elm with a new HTMLElement.

    Parameters

    • elm: HTMLElement

      The element to swap with.

    Returns default

    HTML

  • Sets the text of the current element.

    Parameters

    • val: string

      The text to set to.

    Returns default

    HTML

  • Remove an event listener.

    Parameters

    • ev: string

      The event listener type to remove.

    • cb: EventListenerOrEventListenerObject

      The event listener callback to remove.

    Returns default

    HTML

  • Set the text value of the element. Only works if element is input or textarea.

    Parameters

    • str: any

      The value to set.

    Returns default

    HTML

  • An alternative method to create an HTML instance.

    Parameters

    • elm: string | HTMLElement

      Element to create from.

    Returns null | default

    HTML

  • An easier querySelector method.

    Parameters

    • query: string

      The string to query

    Returns null | default

    a new HTML

  • An easier querySelectorAll method.

    Parameters

    • query: string

      The string to query

    Returns null | (null | default)[]

    a new HTML

Generated using TypeDoc