Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DomUtils

Hierarchy

  • DomUtils

Index

Constructors

constructor

Methods

Static class

  • class(element: HTMLElement, name: string | string[], force?: boolean): boolean | HTMLElement
  • Function returns, add, remove or toggle elements classes

    Parameters

    • element: HTMLElement

      input element

    • name: string | string[]

      class name or data-structures of class names

    • force: boolean = false

      flag if class should be toggled false

    Returns boolean | HTMLElement

    boolean if function is used to check class presence otherwise element given as input

Static createElement

  • createElement(name: string | ObjectCreatorParams, attr?: StringMap<string>, cont?: string | HTMLElement | HTMLElement[], style?: CSSStyleDeclaration): HTMLElement
  • Function crete new element

    ElementManager.createElement("div") =>

    ; ElementManager.createElement("div", {id: "ide"}) =>
    ; ElementManager.createElement("div", {}, "text") =>
    text
    ; ElementManager.createElement("div", {}, "text") =>
    text
    ; ElementManager.createElement("div", {}, "text", {color: "blue"}) =>
    text

    ElementManager.createElement({name: "div"}) =>

    ; ElementManager.createElement({name: "div"}) =>
    ; ElementManager.createElement({name: "div", attr: {id: "ide"}}) =>
    ;

    Parameters

    • name: string | ObjectCreatorParams

      name of element or object contains all configuration

    • Optional attr: StringMap<string>

      map of all element attributes

    • Optional cont: string | HTMLElement | HTMLElement[]

      element content. Can be string, element or array of elements

    • Optional style: CSSStyleDeclaration

      styles that will be applied to the element

    Returns HTMLElement

    created element

Static getWindowHeight

  • getWindowHeight(): number

Static getWindowWidth

  • getWindowWidth(): number

Static html

  • html(element: HTMLElement, html: string | HTMLElement, append?: boolean): HTMLElement
  • Function set, append or returns html content of element

    Parameters

    • element: HTMLElement

      input element

    • html: string | HTMLElement

      html to put in element

    • append: boolean = true

      flag if html should be append or replace previous content

    Returns HTMLElement

    element given as input

Static indexOf

  • indexOf(element: null | Element): number
  • Function returns order of element between siblings

    Parameters

    • element: null | Element

      input element

    Returns number

    index of number

Static position

Static remove

  • remove(element: Element): Element
  • Function remove element

    Parameters

    • element: Element

      input element

    Returns Element

    removed element

Static serialize

  • serialize(form: HTMLFormElement): StringMap<string>

Static size

  • size(element: HTMLElement): Size
  • Function returns object with element size

    Parameters

    • element: HTMLElement

      input element

    Returns Size

    size of element

Static text

  • text(element: HTMLElement, text: string, append?: boolean): HTMLElement
  • Function set, append or returns text of element

    Parameters

    • element: HTMLElement

      input element

    • text: string

      text to put in element

    • append: boolean = true

      flag if text should be append or replace previous text

    Returns HTMLElement

    element given as input

Generated using TypeDoc