Javascript--dom Delete Node removechild ()

Source: Internet
Author: User

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 ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.