2022.2

Table Of Contents
Example
Thefollowingpieceofcodeloadsasnippet,thenlooksforplaceholdersusingfind(),andreplacesthem
withatext.
var mysnippet = loadhtml('snippets/snippet.html');
mysnippet.find('@var1@').text('OL Connect 1');
mysnippet.find('@var2@').html('<i>OL Connect 2</i>').css('text-decoration','underline');
results.replaceWith(mysnippet);
get(index)
ReturnstheelementfoundatthesuppliedindexinasetofHTMLelements.
index
Placeoftheelementintheresultset.Theindexstartscountingatzero.
Example
ThisPostPaginationScriptcopiesthepagenumbersoflevel1and2headingsinallPrintsectionsto
thecorrespondingentryinatable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 );
}
});
Thiscodeisusedinascriptthatinsertsatableofcontents.Forthefullscriptandexplanationsee
"CreatingaTableOfContents"onpage411.
hasClass()
hasClass(classname) : Boolean
ReturnstrueiftheHTMLelementorthefirstelementinaresultsethasthespecifiedclass.
classname
Stringcontainingoneclassname.
Example
Thisscriptchecksifthefirstoftheresults(thesetofelementsmatchingtheselectorofthescript)
hastheclass'green'.Ifso,itcolorsthetextofalltheelementsintheresults green.
if (results.hasClass('green')) {
results.css('color', 'green');
}
Page 765