The DOM object of JavaScript

Source: Internet
Author: User
Tags tag name

Document method

document.createelement (TAG) : Create an HTML tag object

document.getElementById (ID) : An object that obtains the specified ID value

Document.getelementsbyname (name)//Gets the object with the specified Name value

getElementsByTagName (tagName): Returns all element nodes of the specified tag name in the document, returning a list of nodes (which can be seen as arrays)

getelementbyclassname (className): Returns all element nodes of the specified style name in the document, returning a list of nodes (which can be seen as arrays)

createTextNode (text): Create a text node that contains the text of a static literal

CreateAttribute (): Creates a new attr node with the specified name

createcomment (): Creates a new comment node with the specified string

Common Properties for nodes (node)

nodeType : Type of node

nodeName : Name of the node

nodevalue : node value

InnerHTML : Returns all content within a node

parentnode : Returns the parent node of the current node, or null if there is no parent node

childNodes : Returns all child nodes of the current node, stored as an array, and returns an empty array if there are no child nodes

FirstChild : Returns the first child node of the current node. Returns null if there are no child nodes

LastChild : Returns the last child node of the current node, or null if there are no child nodes

nextSibling : Returns the next sibling node of the current node

previoussibing : 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 namenodemap form

Node method

RemoveChild (Childnode): Removes the specified child element from the element

Append (Childnode): Increments the specified node (childnode) to the end of the list of child nodes of the current element (as a new child node)

InsertBefore (Newnode,targetnode): Inserts a node newNode as a child of the current element in front of the TargetNode child node element

ReplaceChild (Newnode,oldnode): Replace the node OldNode with the node NewNode

CloneNode (true): Copy the current node, true to copy the current node and all its descendant nodes

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

getattribute (Name,value): Gets the value of the name attribute in the element

SetAttribute (Name,value): Sets the value of the Name property in the element

RemoveAttribute (name): Remove the attribute from the element name

Hasattribute (name): Returns whether the attribute has a property of the specified name and, if so, returns True

GetAttributeNode (): Returns the value of the specified property in the form of a attr node

Setattributenode (): Adds the specified attr node to the list of elements

Removeattributenode (): Removes the specified attr node from the attribute list of the element

getNamedItem (): Returns the specified node. Often used in conjunction with the attributes attribute



The DOM object of JavaScript

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.