2022.2

Table Of Contents
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");
Selector Matched element Matched element after script execution
.name <div>
<h1>Personalinformation</h1>
<pclass="name"><b>Name:</b></p>
</div>
<div>
<h1>Personalinformation</h1>
<pclass="name"><b>Name:</b><span>PeterParker</span></p>
</div>
Thisscript'sselectoris<div>,sothescriptappendsaparagraphtoallDivelementsinthetemplate.
results.append("<p>Peter Parker</p>");
Page 788