results
The results
object (type: QueryResults
) is the result of the query for HTML elements that match the selector of the script. The selector of a script can be specified in the Script Editor and is visible in the second column of the Scripts pane, next to the name of the script.
If, for example, a script would have the selector p.onlyCanada
, the script would apply to all paragraphs that have the class onlyCanada
. (Classes can be defined in the Attributes pane at the right: select the element in the content and type the class(es) in the Class field.)
The script could then use the results
object to hide or show those paragraphs, depending on the value of the data field Country
in the current record:
if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
Property
Field | Type | Description |
---|---|---|
length |
Number |
Number of elements in this result set. Equivalent to calling size(). |
Functions
The functions below can be called by the results
object and by any other result set that is returned by a query, see query().
Function | Description |
---|---|
add() |
Adds elements to a set of HTML elements. |
addClass() |
Adds the specified class to each element in a set of HTML elements. Has no effect if the class is already present. |
after() | Inserts content after each element in a set of HTML elements.. |
append() |
Inserts content at the end of each element in a set of HTML elements. |
Change the given attribute of the element or set of HTML elements with the given value. |
|
before() | Inserts content before an element or before each element in a set of HTML elements. |
children() | Returns the immediate children of an HTML element. |
clone() | Returns a new result set containing a copy of each element in a set of HTML elements. |
For each element in a set, this function gets the first parent element that matches a selector, by testing the element itself and traversing up through its ancestors in the DOM tree. |
|
css() | Gets the value of a style property for the first element in set of HTML elements or sets one or more CSS properties for every element in a set of HTML elements. |
Removes the contents (child elements and inner HTML) from one element or a set of elements in the template. |
|
Returns a subset of the current result set. |
|
Performs a search for a text in the children of each element in a set of HTML elements, and returns a new result set with elements that surround the occurrences. |
|
get(index) | Returns the element (type: QueryResult) found at the supplied index in a set of HTML elements. |
hasClass() | Returns true if the first element in this result set has the
specified class. |
height() | Gets or sets the outer height of an element, including padding and borders. |
Hides the HTML element or set of HTML elements. |
|
Replaces the inner HTML of the element or of each element in a set of HTML elements with the supplied value, or returns the HTML of the first element if no value is supplied. |
|
info() | Post Pagination Scripts only. Returns pagination information for the first element in this result set. |
is(selector) | Returns true if at least one of the elements in a set of HTML elements matches the supplied CSS selector. |
Returns the next sibling of each HTML element in the result set. |
|
Returns a boolean value indicating whether an HTML element overflows its box boundaries. |
|
pageref() |
Returns a marker that will be replaced with the element's page number after pagination. This only works for elements in the section that is currently being merged. |
parent() | Returns the parents of the elements in a set of HTML elements. |
Returns information about the position (see NodePosition) of the first element in this result set, excluding margins. To include margins, call |
|
prepend() | Inserts content at the beginning of an HTML element or of each element in a set of HTML elements. |
Returns the previous sibling of each HTML element in the result set. |
|
remove() | Removes an HTML element or a set of HTML elements from the document. |
removeAttr() | Removes the specified attribute from each element in this result set. |
removeClass() | Removes the specified class from an element or from each element in a set of HTML elements. Has no effect if the class is not present. |
Replaces an HTML element or a set of HTML elements (with a snippet, for example). Returns the result set. |
|
show() | Shows the HTML element or a set of HTML elements. |
size() | Gets the number of elements in this result set. Equivalent to the length property. |
tagName() | Returns the HTML tag name of the first element in this result set, in uppercase. For an example see: Creating a Table Of Contents. |
text() | Replaces the text content of an HTML element or of each element in a set of HTML elements with the supplied value, or returns the text content of the first element if no value is supplied. |
width() | Gets or sets the outer width of an element, including padding and borders. |