get(index)
Returns the element found at the supplied index in a set of HTML elements.
index
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.