2022.2

Table Of Contents
append()
InsertcontentattheendofoneormoreHTMLelements,whichcanbe:
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:"prepend()"onpage806.
append(content)
InsertscontentasthelastelementattheendofoneormoreHTMLelements.Append()createsanew
resultset.
content
String,HTMLstringorresultsettoinsertaftertheelement(s).Incaseaplaintextstringisprovided,itis
automaticallywrappedina<span>elementtoavoidorphantextnodestoappearinthe<body>ele-
ment.
Examples
Thisscriptappendsaparagraphtotheresults(thesetofHTMLelementsthatmatchtheselectorof
thescript).
results.append("<p>Peter Parker</p>");
Selector Matched element Matched element after script execution
#box <divid="box">
<h1>Personalinformation</h1>
</div>
<divid="box">
<h1>Personalinformation</h1>
<p>PeterParker</p>
</div>
Thisscriptappendsastringtotheresults(theHTMLelementsthatmatchtheselectorofthescript).
Thestringisaddedtotheendofthematchedelement(s)andwrappedinaSpanelement.
results.append("Peter Parker");
Page 753