2022.2

Table Of Contents
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:
var salesrep = query("#salesrep");
salesrep.after("<p>Lorem ipsum</p>");
salesrep.css("color","red");
Thefollowingscriptinsertsaparagraphaftertheelementsintheresults(thesetofHTMLelementsthat
matchtheselectorofthescript).
results.after("<p>Lorem Ipsum</p>");
Page 786