Javascript DOM object, javascriptdom

Source: Internet
Author: User

Javascript DOM object, javascriptdom

Document Method

Document. createElement (Tag): Create an html Tag object

Document. getElementById (ID): Get the object with the specified ID value

Document. getElementsByName (Name)// Obtain the object with the specified Name

GetElementsByTagName (tagName): Return all the Element nodes with the specified calibration name in the document, and return a node list (which can be viewed as an array)

GetElementByClassName (className): Return all Element nodes with the specified style name in the document, and return a node list (which can be viewed as an array)

CreateTextNode (text): Create a text node that contains static text

CreateAttribute (): Create a New Attr node with the specified name

CreateComment (): Create a new comment node with the specified string

Common attributes of a node

NodeType: Node Type

NodeName: Node name

NodeValue: Node Value

InnerHTML: Return all content in the node.

ParentNode: Returns the parent node of the current node. If no parent node exists, null is returned.

ChildNodes: Returns all the subnodes of the current node, which are stored in arrays. If no subnodes exist, an empty array is returned.

FirstChild: Returns the first subnode of the current node. If no subnode exists, null is returned.

LastChild: Returns the last subnode of the current node. If no subnode exists, null is returned.

NextSibling: Returns the next sibling node of the current node.

Previussibing: Returns the previous sibling node of the current node.

Attributes: If the node is an Element node, the attribute of the Element is returned in the form of nameNodeMap.

Node Method

RemoveChild(ChildNode): deletes the specified child element from the element.

Append(ChildNode): add the specified node (childNode) to the end of the subnode list of the current element (as a new subnode)

InsertBefore(NewNode, targetNode): insert the node newNode as the child node of the current element to the front of the child node element of targetNode.

ReplaceChild(NewNode, oldNode): replace node oldNode with node newNode.

CloneNode(True): copy the current node. "true" indicates copying the current node and all its child nodes.

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

GetAttribute(Name, value): obtains the value of the name attribute in the element.

SetAttribute(Name, value): set the value of the name attribute in the element.

RemoveAttribute(Name): deletes the attribute name from an element.

HasAttribute(Name): returns whether this element has the attribute of the specified name. If yes, returns true.

GetAttributeNode(): Returns the value of the specified attribute in the form of an Attr node.

SetAttributeNode(): Add the specified Attr node to the list of this element.

RemoveAttributeNode(): Deletes the specified Attr node from the attribute list of the element.

GetNamedItem(): Return the specified node. Often used in combination with attributes



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.