class Selector
Description
A class that queries the document for elements that match a given CSS selector.
Related utilities
Constructor
new Selector(expression)
-
expression(String) – A CSS selector.
Creates a Selector with the given CSS selector.
Class methods
-
findChildElements #
Selector.findChildElements(element, expressions) ⇒ [Element…]Searches beneath
elementfor any elements that match the selector (or selectors) specified inexpressions. -
findElement #
Selector.findElement(elements, expression[, index = 0]) ⇒ Element
Selector.findElement(elements[, index = 0]) ⇒ ElementReturns the
indexth element in the collection that matchesexpression.Returns the
indexth element overall ifexpressionis not given. -
matchElements #
Selector.matchElements(elements, expression) ⇒ [Element…]Filters the given collection of elements with
expression.The only nodes returned will be those that match the given CSS selector.
-
split #
Selector.split(expression) ⇒ [String…]Takes a string of CSS selectors separated by commas; returns an array of individual selectors.
Safer than doing a naive
Array#split, since selectors can have commas in other places.
Instance methods
-
findElements #
Selector#findElements(root) ⇒ [Element…]- root (Element || document): A "scope" to search within. All results will be descendants of this node.
Searches the document for elements that match the instance's CSS selector.
-
match #
Selector#match(element) ⇒ BooleanTests whether a
elementmatches the instance's CSS selector.