2022.1

Table Of Contents
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, siblings are HTML elements that share the same parent, i.e. HTML elements in the
same container element.
Note that a sibling can be a different type of element. For example, if a paragraph, an image
and a table follow each other in the same Box, they are siblings.
Tip
To get the next sibling, use next() (see "next()" on page1451).
What if there are no siblings?
If you call prev() or next() on a collection of elements (either "results" on page1509 or the
result set of "query()" on page1379), the function will return a collection of siblings. If none of
the elements has a previous or next sibling, the collection will be empty. Actions performed on
an empty collection will simply have no effect.
If you call prev() or next() on a single element (this in an 'Each matched element' script), and
the element has no previous or next sibling, the function returns null. Performing an operation
on a null value will result in an error, which means that the rest of the script won't be executed.
In this case, it is useful to check the return value, unless it's certain that it will never be null.
Example
Assume that there are three consecutive paragraphs in a Box and that the second of those
paragraphs has an ID that matches the selector of this script. The paragraph is stored in the
results object (see "results" on page1509). The following script changes the font-weight of the
previous paragraph - the first paragraph in the Box - to bold.
results.prev().css("font-weight", "bold");
If the elements in results don't have siblings, this line of code will have no effect. It also won't
result in an error.
Page 1419