DOM element attributes and Methods

Source: Internet
Author: User
Used to process DOM element attributes of XML documents

Attribute Name Description

ChildNodes returns an array of all child elements of the current element.

FirstChild returns the first sub-element of the current element.

LastChild returns the last child element of the current element.

NextSibling returns the elements that follow the current element.

NodeValue indicates the read/write attribute of the element value.

ParentNode returns the parent node of the element.

Previussibling returns the element adjacent to the current element.

DOM element method used to traverse XML documents

Method Name Description

GetElementById (id) (document) obtains the elements in the document with the specified unique ID property value.

GetElementsByTagName (name) returns the array of the child elements in the current element specified by the calibration name.

HasChildNodes () returns a Boolean value indicating whether the element has child elements.

GetAttribute (name) returns the attribute value of an element. The attribute is specified by name.

W3C DOM attributes and methods used for dynamic content creation

Attribute/method description

Document. createElement (tagName) allows you to create elements specified by tagName. If the div string is used as the method parameter, a div element is generated.

Document. createTextNode (text) create a node that contains static text

<Element>. appendChild (childNode) adds the specified node to the subnode list of the current element (as a new subnode)

<Element>. getAttribute (name)

<Element>. setAttribute (name, value) obtains and sets the value of the name attribute in the element.

<Element>. insertBefore (newNode, targetNode) inserts the node newNode as the child node of the current element before the targetNode element.

<Element>. removeAttribute (name): This method deletes the attribute name from the element.

<Element>. removeChild (childNode): This method deletes the child element childNode from the element.

<Element>. replaceChild (newNode, oldNode) replaces node oldNode with node newNode

<Element>. hasChildnodes () returns a Boolean value indicating whether the element has child elements.

 

 

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.