15.7 Modifying the DOM Appending, Copying, and Removing Nodes 653 If you want to dynamically remove a post from a blog or an ingredient from an online recipe, it can be done with the DO
Trang 115.7 Modifying the DOM (Appending, Copying, and Removing Nodes) 653
If you want to dynamically remove a post from a blog or an ingredient from an online
recipe, it can be done with the DOM To delete an element or node from the DOM tree,
we use the removeChild() method This method must be called from the parent node
because you will be removing a child It takes a reference to the child it will remove as
its only argument The following examples demonstrate how to dynamically remove
nodes with JavaScript and the DOM The first example, Example 15.15, removes a div
and its contents; the second example, Example 15.16, removes paragraphs
4 A reference to a new div is returned.
5 The cloned table is appended to the div just below the original table (see Figure 15.26)
6 This is the div container for the cloned table.
Figure 15.26 Cloning a table with a unique id.
E X P L A N A T I O N (C O N T I N U E D)
From the Library of WoweBook.Com