Methods
(static) append(parent, …child) → {Node}
Append one or more elements to a parent node
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parent |
ParentNode | ||
child |
Node | String |
<repeatable> |
Returns:
- Type
- Node
(static) clone(el, deepopt) → {Node}
Clone the provided node
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
el |
Node | Node to be cloned | ||
deep |
Bool |
<optional> |
true
|
Returns:
- Type
- Node
(static) create(tagName) → {Element}
Create the HTML element specified by tagName
Parameters:
Name | Type | Description |
---|---|---|
tagName |
String | The tag name of the element to create |
Returns:
- Type
- Element
(static) find(selector) → {HTMLElement}
Get the first matching element
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | CSS selector |
Returns:
- Type
- HTMLElement
(static) findAll(selector) → {NodeList}
Get all the matching elements
Parameters:
Name | Type | Description |
---|---|---|
selector |
String | CSS selector |
Returns:
- Type
- NodeList
(static) findChild(el, selector) → {HTMLElement}
Get the first matching child element
Parameters:
Name | Type | Description |
---|---|---|
el |
Document | |
selector |
String | CSS selector |
Returns:
- Type
- HTMLElement
(static) findChildren(el, selector) → {NodeList}
Get all the matching children elements
Parameters:
Name | Type | Description |
---|---|---|
el |
Document | |
selector |
String | CSS selector |
Returns:
- Type
- NodeList
(static) getCoordinates(el, sideopt) → {Number|Object}
Get the element's coordinates (one side or all sides at once)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
el |
Element | ||
side |
String("top", "right", "bottom", "left") |
<optional> |
Specify the side of which to get the coordinate, or omit the parameter to get an object with all sides |
Returns:
Coordinates in pixels
- Type
- Number | Object
(static) getHeight(el, methodopt) → {Number}
Get the element's height
There are several ways of computing an element height:
layout vs rendered width, with or without the element's borders.
For that matter, this functions supports offsetHeight, clientHeight, scrollHeight and getBoundingClientRect (default).
getBoundingClientRect is used by default but this can by modified by providing one of the above method name
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
el |
Element | |||
method |
String("offsetWidth", "clientWidth", "scrollWidth", "getBoundingClientRect") |
<optional> |
boundingClient
|
Specify an alternate method to use for computation |
Returns:
Size in pixels
- Type
- Number
(static) getNext(el) → {HTMLElement}
Get the element's next sibling
Parameters:
Name | Type | Description |
---|---|---|
el |
Element |
Returns:
- Type
- HTMLElement
(static) getParent(el) → {HTMLElement}
Get the element's parent
Parameters:
Name | Type | Description |
---|---|---|
el |
Node |
Returns:
- Type
- HTMLElement
(static) getPrevious(el) → {HTMLElement}
Get the element's previous sibling
Parameters:
Name | Type | Description |
---|---|---|
el |
Element |
Returns:
- Type
- HTMLElement
(static) getWidth(el, methodopt) → {Number}
Get the element's width
There are several ways of computing an element width:
layout vs rendered width and with or without the element's borders.
For that matter, this functions supports offsetWidth, clientWidth, scrollWidth and getBoundingClientRect (default).
getBoundingClientRect is used by default but this can by modified by providing one of the above method name
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
el |
Element | ||
method |
String("offsetWidth", "clientWidth", "scrollWidth", "getBoundingClientRect") |
<optional> |
Specify an alternate method to use for computation |
Returns:
Size in pixels
- Type
- Number
(static) insertHTML(el, position, text)
Insert an HTML string at "position" relative to the parent element
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | |
position |
String("beforebegin", "afterbegin", "beforeend", "afterend") | |
text |
String |
(static) prepend(parent, …child) → {Node}
Prepend one or more elements to a parent node
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parent |
ParentNode | ||
child |
Node | String |
<repeatable> |
Returns:
- Type
- Node
(static) remove(el)
Remove element from the DOM
Parameters:
Name | Type | Description |
---|---|---|
el |
Node |
(static) removeChild(parent, child) → {HTMLElement}
Remove child element from the DOM and return it
Parameters:
Name | Type | Description |
---|---|---|
parent |
HTMLElement | |
child |
HTMLElement |
Returns:
- Type
- HTMLElement