2022.1

Table Of Contents
The results object contains the elements that match the selector of the script. So, if the script's
selector selects the title of the table of contents, the table of contents will be added after that.
The following style rules, added to the style sheet, will align the chapter titles to the left and the
page numbers to the right:
#toc li {
text-align:left;
}
#toc span {
float: right;
}
Note that these styles use the list's ID, that was defined in the first line of code. For information
about style sheets, see "Styling templates with CSS files" on page786.
parent()
Returns the parent(s) of one or more HTML elements, which can be:
l The elements that match the selector of a script (see "results" on page1509).
l One element that matches the selector of a script that runs for "Each matched element"
(see "this" on page1425 and "Setting the scope of a script" on page924).
l The elements returned by a query in the template (see "query()" on page1379).
In HTML, a parent is an element that contains another element.
To get an ancestor that matches a particular selector, use closest() (see "closest()" on
page1443).
To get an element's sibling element, you can use "prev()" on page1458 or "next()" on
page1451.
Example
Assume that there are three paragraphs in a Box and that one of those paragraphs matches the
selector of this script. The paragraph is stored in the results object (see "results" on
page1509). The following script retrieves the Box (which is the parent of the paragraph) using
results.parent(), and then changes its background color to red.
results.parent().css('background-color' , 'red');
Page 1415