Element

Element, insert, next, toggle

The Element API provides useful functions for manipulating and traversing the DOM. All of these elements are classed under $E. When using the Element or $E function, all Element functions that have their first argument as element are added to the element.

Examples

Element('element_id') -> HTMLElement
$E('element_id') -> HTMLElement

$E('element_id').next() -> HTMLElement
Element.next('element_id') -> HTMLElement

$E('element_id').insert({after: '<p>inserted text</p>'})

Functions

Element

Element(id) -> HTMLElement

Returns the HTML Element for the given id.

- Either an HTMLElement or a string describing the element's id.

Element.insert

Element.insert(element, insertions) -> HTMLElement

Inserts HTML into the page relative to the given element.

- Either an HTML Element or a string describing the element's id.

insertions

OptionDescription
after Inserts the given HTML after the given element.
before Inserts the given HTML before the given element.
bottom Inserts the given HTML at the bottom of the given element's children.
top Inserts the given HTML at the top of the given element's children.

Element.next

Element.next(element) -> HTMLElement

Returns the next sibling element relative to the given element.

- Either an HTML Element or a string describing the element's id.

Element.toggle

Element.toggle(element) -> HTMLElement

Toggles the CSS display property to 'none', or '' if it is already 'none'.

- Either an HTML Element or a string describing the element's id.