2022.2

Table Of Contents
Thiscodeisusedinascriptthatinsertsatableofcontents.Forthefullscriptandexplanationsee
"CreatingaTableOfContents"onpage411.
text()
text() : String
ReturnsthetextcontentofanHTMLelementorofthefirstelementinaresultset(see"results"on
page844).
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).
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);
width()
Getsorsetstheouterwidth,includingpaddingandborders,ofanHTMLelementorofthefirstelement
inresultset(see"results"onpage844),i.e.thesetofHTMLelementsthatmatchtheselectorofthe
scriptorofanotherqueryinthetemplate(see"query()"onpage742).
width(): Number
Returnstheouterwidthofthiselement,includingpaddingandborders,excludingmargins.Toinclude
margins,callwidth(true).
Thereturnedvalueisthewidthinpixels,withoutmeasurementunit(e.g.400).
Page 779