Học JavaScript qua ví dụ part 73 pptx

1 280 0
Học JavaScript qua ví dụ part 73 pptx

Đang tải... (xem toàn văn)

Thông tin tài liệu

ptg 15.7 Modifying the DOM (Appending, Copying, and Removing Nodes) 653 15.7.9 Removing a Node 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. EXPLANATION ( CONTINUED) From the Library of WoweBook.Com . 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

Ngày đăng: 04/07/2014, 02:20

Tài liệu cùng người dùng

Tài liệu liên quan