2022.2

Table Of Contents
if (record.fields["Country"] == "CANADA") {
results.show();
} else {
results.hide();
}
tagName()
ReturnstheHTMLtagnameofoneHTMLelementinuppercase(e.g.H1,P,ARTICLE).
Example
ThisPostPaginationScriptfindslevel1and2headingsinallPrintsectionsandstorestheirpagenum-
ber,textandHTMLtagname.
merge.context.query("h1, h2").each(function() {
var pageNo = this.info().pageNo;
var text = this.text();
var level = this.tagName();
});
Thiscodeisusedinascriptthatinsertsatableofcontents.Forthefullscriptandexplanationsee
"CreatingaTableOfContents"onpage852.
text()
text() : String
ReturnsthetextcontentofanHTMLelementorofthefirstelementinaresultset(see"results"on
page1301).
Example
Thisscriptloadsasnippetintoavariableandretrievesanelementfromthesnippetusingquery()
andtext().
var mysnippet = loadhtml('snippets/text-root-wrapped.html');
var subject = query("#subject", mysnippet).text();
results.append("<p style='font-weight: bold;'>" + subject + "</p>");
text(value)
ReplacesthetextcontentofoneHTMLelementorofeachelementinaresultsetwiththesupplied
value.
Example
Thisscriptloadsasnippet,thenlooksforplaceholdersusingfind(),andreplacesthemusingtext
(value).
Page 1235