Skip to main content

DOM

addClass(ele, cls) ⇒ void

Add a classname to the Element's list of classnames.

ParamTypeDescription
eleelementThe Element to which the new class will be added
clsStringThe class to add to the Element

Example

pendo.dom.addClass(elem, 'foo')

dom(cssSelector) ⇒ DomQuery

Find all Elements that match the CSS Selector.

Returns: DomQuery - array with the matching elements

ParamTypeDescription
cssSelectorstringCSS selector used to search DOM

Example

pendo.dom('h1')[0].remove()

Example

pendo.dom('.left').css({ 'text-align': 'center' })

dom(htmlString) ⇒ DomQuery

Creates new DOM elements from HTML text.

Returns: DomQuery - array with the matching elements

ParamTypeDescription
htmlStringstringHTML syntax used to produce new DOM elements

Example

pendo.dom('<div><span>this should create an unattached DOM node</span></div>');

getClass(ele) ⇒ String

Get the classname for the Element.

ParamTypeDescription
eleelementThe Element referenced for the classname.

Example

var elemClass = pendo.dom.getClass(elem);

hasClass(elem, class) ⇒ Boolean

Check if the Element has this classname.

ParamTypeDescription
elemelementThe Element to test for the classname
classStringThe classname to look for on the element

Example

var hasFooClass = pendo.dom.hasClass(elem, 'foo');

removeClass(ele, cls) ⇒ void

Remove a classname from an Elements classlist.

ParamTypeDescription
eleelementThe Element from which the class will be removed
clsStringThe class to be removed

Example

pendo.dom.removeClass(elem, 'foo')

setClass(ele, cls) ⇒ void

Sets the classname from an Element.

ParamTypeDescription
eleelementThe Element that will get the new classlist.
clsStringThe classname that will be set.

Example

pendo.dom.setClass(elem, 'foo bar baz')