2022.2

Table Of Contents
Selector Paragraph
before script
execution
Paragraph after
script execution
span <p>Loremipsum<span>-
dolorsit</span>amet,con-
sectetueradipiscingelit.</p>
<p>Loremipsumamet,consectetuer
adipiscingelit.</p>
Theselectorofthefollowingsamplescriptistbody.Beforethisscriptruns,thetablebodyconsistsofa
singleplaceholderrowwiththreecells.Afterrunningthescript,itcontainsthirtyrows.Toimproveper-
formance,mostoftheDOMmanipulationtakesplaceondetachedelements.
// Detach the placeholder row from the DOM
var row = query("tr", results).remove();
// Modify the cells of this row
var cells = row.children();
cells[0].html("some text").css("background-color", "yellow");
cells[1].html("some text").css("font-weight", "bold");
cells[2].html("some text");
// Create a number of copies
var rows = row.clone();
for (var i = 0; i < 30; i++) {
rows = rows.add(row.clone());
}
// Attach all copies to the DOM as children of tbody
results.append(rows);
removeAttr()
RemovesthespecifiedHTMLattributefromanelementorfromeachelementinasetofelements.To
addorchangeanattribute,useattr()(see"attr()"onpage1247).
removeAttr(attributeName)
attributeName
String;thenameoftheattribute.
Examples
Thisscriptlooksupanemailfieldinaform(whichisan<input>withtheID#email1)andremovesits
readonlyattribute.
query("#email1").removeAttr('readonly');
Page 1266