2022.1

Table Of Contents
l The elements that match the selector of a script (see "results" on page958).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page877 and "Setting the scope of a script" on page395).
l The elements returned by a query in the template (see "query()" on page831).
To get a child element or all child elements, use children() (see "children()" on page893).
The closest() command is based on the closest() command found in the jQuery library:
https://api.jquery.com/closest/.
To get an element's sibling element, you can use "prev()" on page909 or "next()" on page902.
closest(selector)
For one HTML element or for each element in a set, this function gets the first element that
matches the selector by testing the element itself and traversing up through its ancestors in the
DOM tree.
selector
A String containing an HTML tag (without the angle brackets, <>).
Examples
The following script looks up all table rows in the template that contain an <input> element.
query("input").closest("tr");
This code gets the closest 'parent' row for each element that matches the selector of the script
(collected in the results object):
results.closest("tr");
The rows could be colored red within the same statement:
results.closest("tr").css('background-color','red');
css()
Gets the value of a style property of one HTML element, or sets one or more CSS properties of
one or more HTML elements.
Page 895