Selectors Utility

The selectors utility contains functions to get HTML elements by different selectors.

Table of Contents

  1. Using Selectors in the Web UI framework
  2. Methods

Using Selectors in the Web UI framework

To use selectors in Web UI framework, use the following code:

tau.util.selectors.getChildrenByClass(HTMLElement, "className");

Methods

Summary

Method Description
Array getAllByDataNS ( HTMLElement context, string dataSelector ) 

Returns an array of elements from the context with a given data-selector.

Array getChildrenByClass ( HTMLElement context, string className ) 

Returns an array with children with a given class name.

Array getChildrenByDataNS ( HTMLElement context, string dataSelector ) 

Returns an array with children passed by a given data-namespace-selector.

Array getChildrenBySelector ( HTMLElement context, string selector ) 

Returns an array with children passed by a given selector.

Array getChildrenByTag ( HTMLElement context, string tagName ) 

Returns an array with children with a given tag name.

HTMLElement getClosestByClass ( HTMLElement context, string selector ) 

Returns the first element from the parents of an element with a given class name.

HTMLElement getClosestBySelector ( HTMLElement context, string selector ) 

Returns the first element from the parents of an element passed by a selector.

HTMLElement getClosestBySelectorNS ( HTMLElement context, string selector ) 

Returns the first element from the parents of an element passed by a selector with a namespace.

HTMLElement getClosestByTag ( HTMLElement context, string selector ) 

Returns the first element from the parents of an element with a given tag name.

Array getParents ( HTMLElement context, string selector ) 

Returns an array with all the parents of an element.

Array getParentsByClass ( HTMLElement context, string className ) 

Returns an array with all the parents of an element with a given class name.

Array getParentsBySelector ( HTMLElement context, string selector ) 

Returns an array with all the parents of an element passed by a given selector.

Array getParentsBySelectorNS ( HTMLElement context, string selector ) 

Returns an array with all the parents of an element passed by a given selector with a namespace.

Array getParentsByTag ( HTMLElement context, string tagName ) 

Returns an array with all the parents of an element with a given tag name.

boolean matchesSelector ( HTMLElement element, string selector ) 

Runs the match implementation of the matchesSelector method on a specified element.

getAllByDataNS

Returns an array of elements from the context with a given data-selector.

Array getAllByDataNS ( HTMLElement context, string dataSelector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
dataSelector string Required

Return value:

Type Description
Array
getChildrenByClass

Returns an array with children with a given class name.

Array getChildrenByClass ( HTMLElement context, string className) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
className string Required

Return value:

Type Description
Array
getChildrenByDataNS

Returns an array with children passed by a given data-namespace-selector.

Array getChildrenByDataNS ( HTMLElement context, string dataSelector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
dataSelector string Required

Return value:

Type Description
Array
getChildrenBySelector

Returns an array with children passed by a given selector.

Array getChildrenBySelector ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
Array
getChildrenByTag

Returns an array with children with a given tag name.

Array getChildrenByTag ( HTMLElement context, string tagName) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
tagName string Required

Return value:

Type Description
Array
getClosestByClass

Returns the first element from the parents of an element with a given class name.

HTMLElement getClosestByClass ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
HTMLElement
getClosestBySelector

Returns the first element from the parents of an element passed by a selector.

HTMLElement getClosestBySelector ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
HTMLElement
getClosestBySelectorNS

Returns the first element from the parents of an element passed by a selector with a namespace.

HTMLElement getClosestBySelectorNS ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
HTMLElement
getClosestByTag

Returns the first element from the parents of an element with a given tag name.

HTMLElement getClosestByTag ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
HTMLElement
getParents

Returns an array with all the parents of an element.

Array getParents ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
Array
getParentsByClass

Returns an array with all the parents of an element with a given class name.

Array getParentsByClass ( HTMLElement context, string className) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
className string Required

Return value:

Type Description
Array
getParentsBySelector

Returns an array with all the parents of an element passed by a given selector.

Array getParentsBySelector ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
Array
getParentsBySelectorNS

Returns an array with all the parents of an element passed by a given selector with a namespace.

Array getParentsBySelectorNS ( HTMLElement context, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
selector string Required

Return value:

Type Description
Array
getParentsByTag

Returns an array with all the parents of an element with a given tag name.

Array getParentsByTag ( HTMLElement context, string tagName) 

Parameters:

Parameter Type Required/optional Default value Description
context HTMLElement Required
tagName string Required

Return value:

Type Description
Array
matchesSelector

Runs the match implementation of the matchesSelector method on a specified element.

boolean matchesSelector ( HTMLElement element, string selector) 

Parameters:

Parameter Type Required/optional Default value Description
element HTMLElement Required
selector string Required

Return value:

Type Description
boolean