2022.2

Table Of Contents
l
Theelementsthatmatchtheselectorofascript(see"results"onpage1301).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage1237and"Settingthescopeofascript"onpage813).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage1197).
add(content)
Theadd()functionaddsHTMLcontenttooneormoreHTMLelementsandreturnstheunionofthisres-
ultorresultsetandothercontent.
content
Aqueryresult.ThiscanbeanHTMLstringoraresultset.
Examples
Thisscriptaddsonequeryresulttoanotherandsetsthebackgroundcolortoyellow.
query("#test1").add(query("#test2")).css("background", "yellow");
Note: Thewaythefunctionsadd()andcss()areusedinthisscriptiscalled'chaining'.Chaining
isoptional;thesamecouldbeachievedbystoringtheresultsofthequeriesinavariable:
var myResult = query("#test1");
myResult.add(query("#test2");
myResult.css("background", "yellow");
Thefollowingscriptloadssnippetsinaniterationandaddstheirelementstoanemptyresultset(using
query()).Thenitreplacesaplaceholderinthetemplatewiththenewresult.
var chapters = query();
for ( var i = 1; i <= 4; i++) {
chapters = chapters.add(loadhtml('snippets/Chapter' + i + '.html'));
}
results.replaceWith(chapters);
Page 1240