2022.2

Table Of Contents
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).
Use"remove()"onpage810toremovetheelementsthemselves.
Example
ThisscriptemptiesallSpanelementsfoundinthetemplate.
results.empty();
Selector Paragraph
before script
execution
Paragraph after script
execution
span <p>Loremipsum<span>-
dolorsit</span>amet,con-
sectetueradipiscingelit.</p>
<p>Loremipsum<span></span>amet,
consectetueradipiscingelit.</p>
find()
find(textToFind)
PerformsadeepsearchfortextToFindinthechildrenofeachelement,andreturnsanewresultset
withelementsthatsurroundtheoccurrences.
textToFind
AStringthatcontainsthesearchtext.
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);
Page 798