API Docs for:
Show:

DOM Class

Defined in: latest/dom.js:7
Module: DOM
Parent Module: JSFramework

DOM methods

Item Index

Methods

Properties

Methods

create

(
  • tag
  • [properties={}]
  • [wrap=true]
  • [attributes={}]
)
ElementWrapper | HTMLElement

Defined in latest/dom.js:30

Create and return a new wrapped DOM element

Parameters:

  • tag String

    Tag name to create (eg. "span")

  • [properties={}] Object optional

    Properties to set on the new element

  • [wrap=true] Boolean optional

    Whether to wrap the element or not. Optional, default is true

  • [attributes={}] Object optional

    Attributes to set on the new element

Returns:

ElementWrapper | HTMLElement: The new element (or a wrapper if wrap is true)

Example:

var newEl = DOM.create('div',
{
    id: 'hello-world',
    className: 'awesome',
    innerHTML: 'This is a test!'
}); // Creates <div id="hello-world" class="awesome">This is a test!</div>

wrap

(
  • el
)
ElementWrapper

Defined in latest/dom.js:66

Wrap an element with useful functions. This creates an instance of ElementWrapper that "wraps" the passed element. The $ method can be used as a shortcut to this.

Parameters:

  • el HTMLElement | ElementWrapper | String

    Either the ID of the element, or the element itself

Returns:

ElementWrapper: An ElementWrapper instance

Example:

var containerEl = DOM.wrap('container'); // Gets the element with an ID of "container"
var containerEl = $('container');        // Exact same as above - $ is an alias for DOM.wrap

wrapAll

(
  • input
)
Array of ElementWrapper

Defined in latest/dom.js:100

Wrap all the passed elements

Parameters:

  • input Array of HTMLElement

    Array of elements

Returns:

Array of ElementWrapper: Array of wrapped elements

Example:

// Get all DIVs on the page, and create an ElementWrapper for each
var wrapped = DOM.wrapAll(document.getElementsByTagName('div'));

Properties

body

ElementWrapper

Defined in latest/dom.js:115

Body of the page

cache

Array private

Defined in latest/dom.js:16

Cache of ElementWrappers

JS_ELEMENT_ID

Unknown final

Defined in latest/dom.js:23

Name of the attribute used to store an element ID number in the cache