1.4

<p>Lorem dolor sit amet,
consectetur adipiscing elit.</p>
<p>Lorem<span>ipsum</span>dolor sit amet,
consectetur adipiscing elit.</p>
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 contentat the end of each element in the set of each element in a set of HTML elements
that match the selector of the script or of another query in the template (see "query()" on page
209).See also: "prepend()" on page 206.
append(content)
Insert content as the last element toeach element in the set of HTML elements that match the
selector of the script or of another query in the template (see "query()" on page 209). Append
creates a new result set.
content
String, HTML string or result set to insert after the 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 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 183