Replacing Nodes

While you can always delete existing nodes and insert new nodes, it’s simpler to just replace nodes if that’s what you want. Scripts 11.9 (the HTML) and 11.10 show how you can replace one node with another. Figure 11.7 shows the replacement process.

Figure 11.7. Here, we’ve replaced the third paragraph (left) with new text (right).
Script 11.9. Adding the Replace node radio button to the HTML rounds out our node manipulation examples.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns=""> <head> ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.