Nodes

Nodes

Source:
Getting, removing and setting elements (or their info) related functions

Methods

(static) append(parent, …child) → {Node}

Source:
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}

Source:
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}

Source:
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}

Source:
Get the first matching element
Parameters:
Name Type Description
selector String CSS selector
Returns:
Type
HTMLElement

(static) findAll(selector) → {NodeList}

Source:
Get all the matching elements
Parameters:
Name Type Description
selector String CSS selector
Returns:
Type
NodeList

(static) findChild(el, selector) → {HTMLElement}

Source:
Get the first matching child element
Parameters:
Name Type Description
el Document
selector String CSS selector
Returns:
Type
HTMLElement

(static) findChildren(el, selector) → {NodeList}

Source:
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}

Source:
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

Source:
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}

Source:
Get the element's next sibling
Parameters:
Name Type Description
el Element
Returns:
Type
HTMLElement

(static) getParent(el) → {HTMLElement}

Source:
Get the element's parent
Parameters:
Name Type Description
el Node
Returns:
Type
HTMLElement

(static) getPrevious(el) → {HTMLElement}

Source:
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

Source:
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)

Source:
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}

Source:
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)

Source:
Remove element from the DOM
Parameters:
Name Type Description
el Node

(static) removeChild(parent, child) → {HTMLElement}

Source:
Remove child element from the DOM and return it
Parameters:
Name Type Description
parent HTMLElement
child HTMLElement
Returns:
Type
HTMLElement