Element. Selectors.js

Css Query related functions and Element extensions

License

MIT-style license.

Summary
Element. Selectors.jsCss Query related functions 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.
getElementSame as Element.getElements, but returns only the first.
getElementsBySelectorSame as Element.getElements, but allows for comma separated selectors, as in css.
getElementByIdTargets an element with the specified id found inside the Element.

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

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

Arguments

selectorstring; the 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

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 as Elements.

Returns

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

Arguments

selectorstring; css 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.
getElementSame as Element.getElements, but returns only the first.
getElementsBySelectorSame as Element.getElements, but allows for comma separated selectors, as in css.
getElementByIdTargets an element with the specified id found inside the Element.

Properties

getElements

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

Arguments

selectorstring; the css selector to match

Examples

$('myElement').getElements('a'); // get all anchors within myElement
$('myElement').getElements('input[id=dialog]') //get all input tags with name 'dialog'
$('myElement').getElements('input[name$=log]') //get all input tags with names ending with 'log'

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.

getElement

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

Arguments

selectorstring; css selector

getElementsBySelector

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

Arguments

selectorstring; css selector

getElementById

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

Arguments

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

Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi