2022.2

Table Of Contents
Examples
Replace elements with a snippet
Thefollowingscriptloadsasnippetandthenreplacestheelementsmatchedbythescript'sselector
withthesnippet.
var snippet = loadhtml('snippets/mysnippet.html');
results.replaceWith(snippet);
Replace elements with a set of snippets
Thefollowingscriptloadssnippetsandaddstheirelementstoanew,emptyresultset(usingquery
()).Thenitreplacesaplaceholderinthetemplatewiththesetofsnippets.
var chapters = query();
for ( var i = 1; i <= 4; i++) {
chapters = chapters.add(loadhtml('snippets/Chapter' + i + '.html'));
}
results.replaceWith(chapters);
show()
ShowsoneormoreHTMLelements,whichcanbe:
l
Theelementsthatmatchtheselectorofascript(see"results"onpage844).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage781and"Settingthescopeofascript"onpage373).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage742).
Tohideelements(again),usethefunction"hide()"onpage801.
ThesefunctionsareusedbytheConditionalScriptWizard,asyoucanseewhenyouopenaCondi-
tionalScriptandclicktheExpandbutton;see"Showingcontentconditionally"onpage318.
Example
Thisscripthidesorshowstheelementsmatchedbytheselectorofthescript(whicharestoredinthe
resultsobject),dependingonthevalueofthedatafieldCountryinthecurrentrecord.
if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
tagName()
ReturnstheHTMLtagnameofoneHTMLelementinuppercase(e.g.H1,P,ARTICLE).
Page 811