Namespace: dom

caph. dom

Classes

Element

Namespaces

event

Methods

<static> getElement(selector, single, root) → {caph.dom.Element}

Returns the matched elements found in the DOM based on passed arguments.

Parameters:
Name Type Argument Description
selector String

A string containing a selector expression. See http://www.w3schools.com/cssref/css_selectors.asp for more details.

single Boolean <optional>

A Boolean indicating whether to get the first matched element only. If uses id selector, this parameter will be ignored.

root HTMLElement | caph.dom.Element <optional>

A HTML Element or caph.dom.Element to use as context. If uses id selector, this parameter will be ignored.

Since:
  • 2.0.0
Returns:
Type
caph.dom.Element
Example
caph.dom.getElement("#id"); // id selector
 caph.dom.getElement(".class") // class selector
 caph.dom.getElement(".class", true) // class selector with single parameter
 caph.dom.getElement(".class", element) // class selector with root parameter
 caph.dom.getElement(".class", true, element) // class selector with single and root parameter
 caph.dom.getElement("div") // tag name selector
 caph.dom.getElement("div", true) // tag name selector with single parameter
 caph.dom.getElement("div", element) // tag name selector with root parameter
 caph.dom.getElement("div", true, element) // tag name selector with single and root parameter
 caph.dom.getElement("li:nth-child(odd)") // query selector
 caph.dom.getElement("li:nth-child(odd)", true) // query selector with single parameter
 caph.dom.getElement("li:nth-child(odd)", element) // query selector with root parameter
 caph.dom.getElement("li:nth-child(odd)", true, element) // query selector with single and root parameter