Delete Node removechild ()
The RemoveChild () method removes a node from the list of child nodes. If the deletion succeeds, this method returns the node that was deleted, such as failure, and returns NULL.
Grammar:
Nodeobject.removechild (node)
Parameters:
Node: required, specify the node that needs to be deleted.
Let's take a look at the code below and delete the child points.
Operation Result:
Content of the HTML delete node: JavaScript
Note: Assign the deleted child node to x, which is not in the DOM tree, but still exists in memory and can be manipulated by X.
If you want to completely delete an object, assign a null value to X, the code is as follows:
Replace element node ReplaceChild ()
ReplaceChild implements the substitution of child nodes (objects). Returns a reference to the object being replaced.
Grammar:
Parameters:
NewNode: Required to replace the Oldnew object.
Oldnew: Required, object replaced by NewNode.
Let's take a look at the following code:
Effect: Change Java in the document to JavaScript.
Attention:
1. When OldNode is replaced, all attribute content associated with it will be removed.
2. NewNode must be established first.
Task
Try adding the function replacemessage () code to replace the B tag with the I tag.
Javascript--dom Delete Node removechild ()