1.6

Table Of Contents
Selector Paragraph
before script
execution
Paragraph after
script execution
<span>dolor
sit</span> amet,
consectetuer
adipiscing
elit.</p>
amet, consectetuer
adipiscing elit.</p>
The selector of the following sample script is tbody. Before this script runs, the table body
consists of a single placeholder row with three cells. After running the script, it contains thirty
rows. To improve performance, most of the DOM manipulation takes place 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 the specified HTML attribute from an element or from each element in a set of
elements. To add or change an attribute, use attr() (see "attr()" on page751).
Page 790