Class: HtmlElementUtils

Kekule. HtmlElementUtils

new HtmlElementUtils()

Utils methods for HTML elements.
Source:

Methods

(static) addClass(elem, className)

Add class name(s) to element.
Parameters:
Name Type Description
elem HTMLElement
className Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings.
Source:

(static) getClassNames(elem) → {Array}

Get classes used by element.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
Type
Array

(static) getElemBoundingClientRect(elem, includeScroll) → {Hash}

Returns bounding client rectangle for element.
Parameters:
Name Type Description
elem HTMLElement
includeScroll Bool If this value is true, scrollTop/Left of documentElement will be added to result.
Source:
Returns:
{top, left, bottom, right, width, height}
Type
Hash

(static) getElemClientDimension(elem) → {Hash}

Get element client width and height.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
A combination of {width, height}, in px.
Type
Hash

(static) getElemComputedDimension(elem) → {Hash}

Returns computed width/height in px.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
A combination of {width, height}, in px.
Type
Hash

(static) getElemOffsetDimension(elem) → {Hash}

Get element offset width and height.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
A combination of {width, height}, in px.
Type
Hash

(static) getElemPagePos(elem) → {Hash}

Get position relative to top-left corner of HTML page.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
Type
Hash

(static) getElemScrollDimension(elem) → {Hash}

Get element scroll width and height.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
A combination of {width, height}, in px.
Type
Hash

(static) getElemViewportPos(elem) → {Hash}

Get position relative to top-left corner of viewport.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
Type
Hash

(static) getInnerText(elem) → {String}

Returns text (without tag) inside an element.
Parameters:
Name Type Description
elem HTMLElement
Source:
Returns:
Type
String

(static) getViewportDimension(elemOrViewport) → {Hash}

Get size of view port.
Parameters:
Name Type Description
elemOrViewport Variant
Source:
Returns:
Type
Hash

(static) hasClass(elem, className) → {Bool}

Check if a class is associate with element.
Parameters:
Name Type Description
elem HTMLElement
className String
Source:
Returns:
Type
Bool

(static) isFormCtrlElement(elem)

Check if element is a form control (input, button, select and textarea).
Parameters:
Name Type Description
elem
Source:

(static) makePositioned(elem)

Set element's position style to make it to a absolute, relative or fixed one (but retain element's position).
Parameters:
Name Type Description
elem HTMLElement
Source:

(static) removeClass(elem, className)

remove class(es) from element.
Parameters:
Name Type Description
elem HTMLElement
className Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings.
Source:

(static) resizeElem(elem, width, height, unit)

Resize a HTML element.
Parameters:
Name Type Description
elem HTMLElement
width Number
height Number
unit String Default is px.
Source:

(static) toggleClass(elem, className)

Toggle class(es) from element.
Parameters:
Name Type Description
elem HTMLElement
className Variant Can be a simple name, or a series of name separated by space ('name1 name2') or an array of strings.
Source: