Dom.js

Css Query related function and Element extensions

Authors

License

MIT-style license.

Summary
Dom.jsCss Query related function and Element extensions
Utility Functions
Functions
$ESelects a single (i.e.
$ESReturns a collection of Elements that match the selector passed in limited to the scope of the optional filter.
ElementCustom class to allow all of its methods to be used with any DOM element via the dollar function $.
Properties
getElementsGets all the elements within an element that match the given (single) selector.
getElementByIdTargets an element with the specified id found inside the Element.
getElementSame as Element.getElements, but returns only the first.
getElementsBySelectorSame as Element.getElements, but allows for comma separated selectors, as in css.
document related functions
Functions
document. getElementsByClassNameReturns all the elements that match a specific class name.
ElementsMethods for dom queries arrays, $$.

Utility Functions

Summary
Functions
$ESelects a single (i.e.
$ESReturns a collection of Elements that match the selector passed in limited to the scope of the optional filter.

Functions

$E

function $E(selector,
filter)

Selects a single (i.e. the first found) Element based on the selector passed in and an optional filter element.

Arguments

selectorthe css selector to match
filteroptional; a DOM element to limit the scope of the selector match; defaults to document.

Example

$E('a', 'myElement') //find the first anchor tag inside the DOM element with id 'myElement'

Returns

a DOM elementthe first element that matches the selector

$ES

function $ES(selector,
filter)

Returns a collection of Elements that match the selector passed in limited to the scope of the optional filter.  See Also: Element.getElements for an alternate syntax.

Returns

an array of dom elements that match the selector within the filter

Arguments

selectorcss selector to match
filteroptional; a DOM element to limit the scope of the selector match; defaults to document.

Examples

$ES("a") //gets all the anchor tags; synonymous with $$("a")
$ES('a','myElement') //get all the anchor tags within $('myElement')

Element

Custom class to allow all of its methods to be used with any DOM element via the dollar function $.

Summary
Properties
getElementsGets all the elements within an element that match the given (single) selector.
getElementByIdTargets an element with the specified id found inside the Element.
getElementSame as Element.getElements, but returns only the first.
getElementsBySelectorSame as Element.getElements, but allows for comma separated selectors, as in css.

Properties

getElements

Gets all the elements within an element that match the given (single) selector.

Arguments

selectorthe css selector to match

Example

$('myElement').getElements('a'); // get all anchors within myElement

Notes

Supports these operators in attribute selectors:

  • = : is equal to
  • ^= : starts-with
  • $= : ends-with
  • != : is not equal to

Xpath is used automatically for compliant browsers.

getElementById

Targets an element with the specified id found inside the Element.  Does not overwrite document.getElementById.

Arguments

idthe id of the element to find.

getElement

Same as Element.getElements, but returns only the first.  Alternate syntax for $E, where filter is the Element.

getElementsBySelector

Same as Element.getElements, but allows for comma separated selectors, as in css.  Alternate syntax for $$, where filter is the Element.

document related functions

Summary
Functions
document. getElementsByClassNameReturns all the elements that match a specific class name.

Functions

document. getElementsByClassName

Returns all the elements that match a specific class name.  Here for compatibility purposes. can also be written: document.getElements(‘.className’), or $$(‘.className’)

Elements

Methods for dom queries arrays, $$.

function $(el)
returns the element passed in with all the Element prototypes applied.
Custom class to allow all of its methods to be used with any DOM element via the dollar function $.
function $E(selector,
filter)
Selects a single (i.e.
function $ES(selector,
filter)
Returns a collection of Elements that match the selector passed in limited to the scope of the optional filter.
Gets all the elements within an element that match the given (single) selector.
function $$()
Selects, and extends DOM elements.