2020.1

Table Of Contents
The new result set is of the type QueryResults, just like the results object which is also the
result of a (hidden) query. All functions that can be used with the results object can also be
used with this result set; see "results" on page909.
Note
The query() function can't be used in a Control Script, since Control Scripts don't have access to
the DOM.
query(selector)
Creates a new result set containing the HTML elements in the current section that match the
supplied CSS selector.
selector
A String containing a CSS selector. See https://www.w3schools.com/cssref/css_selectors.asp
for CSS selectors and combinations of CSS selectors.
Examples
Look for an element with a certain ID
This scripts applies a style rule to the queried elements.
query("#test1").css("color", "yellow");
Matched element Matched element after script execution
<p id="test1">foo</p> <p id="test1" style="color: yellow;">foo</p>
Look for an element in a snippet
The following script loads a snippet. Then it looks up an element in a snippet and sets its text.
Finally, it replaces the elements matched by the script's selector by the snippet.
var snippet = loadhtml('snippets/mysnippet.html');
query("#foo", snippet).text("bar");
results.replaceWith(snippet);
Page 793