2022.2

Table Of Contents
var a = loadhtml('snippets/snippet.html');
results.prepend(a);
Selector Matched element Matched element after script execution
div <divid="box">
<p>PeterParker</p>
</div>
<divid="box">
<h1>Personalinformation</h1>
<p>PeterParker</p>
</div>
Thisscriptusesthefunctionquery()tofindabox.Thenitinsertsaheadingasthefirstelementinthat
box.
query("#box").prepend("<h1>Personal information</h1>");
Matched element Matched element after script execution
<divid="box">
<p>PeterParker</p>
</div>
<divid="box">
<h1>Personalinformation</h1>
<p>PeterParker</p>
</div>
Thisscriptusesthefunctionquery()tofindabox,prependsaheadingandsetsthetextcolorofthe
entireboxtored.
query("#box").prepend("<h1>Personal information</h1>").css("color","red");
Matched element Matched element after script execution
<divid="box">
<p>PeterParker</p>
</div>
<divid="box"style="color:red;">
<h1>Personalinformation</h1>
<p>PeterParker</p>
</div>
Note: Thewaythefunctionsprepend()andcss()areusedinthisscriptiscalled'chaining'.Chain-
ingisoptional;thesamecouldbeachievedbystoringtheresultofthequeryinavariable:
Page 1230