2020.2

Table Of Contents
This script looks up an element with the ID #salesrep and inserts a string after it. The string is
automatically enclosed in a span.
query("#salesrep").after("Lorem Ipsum");
Matched element Matched element after script execution
<p id="salesrep">Peter Parker</p> <p id="salesrep">Peter Parker</p>
<span>Lorem Ipsum</span>
append()
Insert contentat the end of one or more HTML elements, which can be:
l The elements that match the selector of a script (see "results" on page1420).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page1338 and "Setting the scope of a script" on page860).
l The elements returned by a query in the template (see "query()" on page1293).
See also: "prepend()" on page1368.
append(content)
Inserts content as the last element at the end of one or more HTML elements. Append() creates
a new result set.
content
String, HTML string or result set to insert after the element(s). In case a plain text string is
provided, it is automatically wrapped in a <span> element to avoid orphan text nodes to
appear in the <body> element.
Examples
This script appends a paragraph to the results (the set of HTML elements that match the
selector of the script).
results.append("<p>Peter Parker</p>");
Page 1306