2021.2

Table Of Contents
Selector Matched element Matched element after script execution
p <p>Hello world</p> <p class="foo bar">Hello world</p>
The following script adds two class names to a paragraph.
results.addClass("foo bar");
Selector Matched element Matched element after script execution
p <p>Hello world</p> <p class="foo bar">Hello world</p>
after()
Inserts content after one or more HTML elements, which can be:
l The elements that match the selector of a script (see "results" on page1448).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page1364 and "Setting the scope of a script" on page883).
l The elements returned by a query in the template (see "query()" on page1319).
See also: "before()" on page1377.
after(content)
Inserts contentafter one or more HTML elements and creates a new result set.
content
String, HTML string or result set to insert after the matched elements. 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 looks up an element with the ID #salesrep and inserts a paragraph after it.
query("#salesrep").after("<p>Lorem ipsum</p>");
Page 1371