2022.1

Table Of Contents
Place of the element in the result set. The index starts counting at zero.
Example
This Post Pagination Script copies the page numbers of level 1 and 2 headings in all Print
sections to the corresponding entry in a table of contents.
var $numbers = query('.number');
merge.context.query("h1, h2").each(function( index ) {
var pageNo = this.info().pageNo;
var entry = $numbers.get( index );
if( entry ) {
entry.text( pageNo );
}
});
This code is used in a script that inserts a table of contents. For the full script and explanation
see "Creating a Table Of Contents" on page972.
hasClass()
hasClass(classname) : Boolean
Returns true if the HTML element or the first element in a result set has the specified class.
classname
String containing one class name.
Example
This script checks if the first of the results (the set of elements matching the selector of the
script) has the class 'green'. If so, it colors the text of all the elements in the results green.
if (results.hasClass('green')) {
results.css('color', 'green');
}
height()
Gets or sets the outer height, including padding and borders, of an HTML element, or of the first
element in a result set (see "results" on page1509), i.e. the set of HTML elements that match
the selector of the script or of another query in the template (see "query()" on page1379).
Page 1408