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).
Seealso:"before()"onpage792.
after(content)
InsertscontentafteroneormoreHTMLelementsandcreatesanewresultset.
content
String,HTMLstringorresultsettoinsertafterthematchedelements.Incaseaplaintextstringis
provided,itisautomaticallywrappedina<span>elementtoavoidorphantextnodestoappearinthe
<body>element.
Examples
ThisscriptlooksupanelementwiththeID#salesrepandinsertsaparagraphafterit.
query("#salesrep").after("<p>Lorem ipsum</p>");
Matched element Matched element after script execution
<pid="salesrep">PeterParker</p> <pid="salesrep">PeterParker</p>
<p>Loremipsum</p>
ThisscriptlooksupanelementwiththeID#salesrep,setsitstextcolortoredandinsertsaparagraph
afterit.
query("#salesrep").after("<p>Lorem ipsum</p>").css("color","red");
Matched element Matched element after script execution
<pid="salesrep">PeterParker</p> <pid="salesrep"style="color:red;">PeterParker</p>
<p>Loremipsum</p>
Notethatthewaythefunctionsafter()andcss()areusedinthisscriptiscalled'chaining'.Chainingis
optional;thesamecouldbeachievedbystoringtheresultofthequeryinavariable:
Page 751