268Part IIIDocument Objects ReferenceInvoking the replaceChild()method in the (Domain and web hosting)

268Part IIIDocument Objects ReferenceInvoking the replaceChild()method in the replace()function utilizes some of the samecode. The main difference is that the replaceChild()method requires a second parameter: a reference to the child element to be replaced. This demonstration replaces the final childnode of the ullist, so the function takes advantage of the lastChildproperty of all elementsto get a reference to that final nested child. That reference becomes the second parameter toreplaceChild(). Listing 15-21: Various Child Methods

Child Methods


Here is a list of items:
  • First Item
  • Second Item
Enter some text to add/replace in the list:

elementObject.appendChild()