2022.2

Table Of Contents
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>");
Matched element Matched element after script execution
<pid="salesrep">PeterParker</p> <pid="salesrep">PeterParker</p>
<p>Loremipsum</p>
Thisscriptlooksforthestring"Lorem"intheresults(thesetofHTMLelementsthatmatchtheselector
ofthescript)andinsertsthestring"ipsum"rightafterthattext.Thestringisautomaticallyenclosedina
span.
results.find("Lorem ").after("ipsum");
Matched element Matched element after script execution
<p>Loremdolorsitamet,consecteturadipiscingelit.</p> <p>Lorem<span>ipsum</span>dolorsitamet,consecteturadipiscingelit.</p>
Page 1243