JavaScript_Dom_API
1, node (html all of the content can be considered a node, such as: doctype, html, head, comments, div contents "hello", spaces, carriage returns all nodes)
1) Basic attribute information acquiring node:
nodeType; node type
nodeName; element tag name
the nodeValue; value of the element
2) indicates that the property hierarchy:
parentNode; parent
parentElement; parent element
ownerDocument; where the document object of the current element
childNode; child node
firstChild; childNode first node
lastChild; childNode last node
Next node sibling nodes; the nextSibling
A sibling node before the node; previousSibling
3) Other methods:
(1) method of the parent node calls:
the appendChild (); adding a node to the end of the list childNode
insertBefore (new, reference); insert a new node. new: node to be inserted; reference: as a reference node
replaceChild (new, old); replacing a node. new: node to be inserted; reference: the node to replace
removeChild (v); removing a node. v: To remove a node
cloneNode ([boolean]); replicate sites. If the argument is true, that deep copy
2, Document (document, representing the entire document html or xml file, a html generally be used to represent an instance of Document, i.e., document)
1) Find the element method:
the getElementById (); Get element ID
getElementsByClassName (); Gets the element class name
getElementsByTagName (); Gets the element tag name
getElementsByName (); Gets the element name
2) Selector:
querySelector (); return element in the document that match the specified CSS selectors
Returns a list of elements that match a specified group of selected documents; querySelectorAll ()
3, Element (elements, all the elements html document can be mapped to an Element instance)
1) element hierarchy related attributes:
children; child node (only contains Element object)
firstElementchild; first child element node
lastElementchild; the last child node
nextElementSibling; next sibling node
previousElementSibling; a sibling node
the innerHTML; Gets or sets an element in the html content
the innerText; Gets or sets the contents of a text element
textContent;
2) Related Properties Method:
getAttribute (key); custom property acquired. key: attribute name is the actual element
setAttribute (key, val); set properties. key: name of a characteristic to be set; val: is the corresponding value, if the value exists, replacing
removeAttribute (); Removes the specified attribute
A document that match the specified element returns CSS selector; querySelector (selector)
querySelectorAll (selector); Returns a list of elements that match a specified group of selected documents
4, Text (text, text, follows "hello world" represents the textual content <div> hello world </ div>)
1) text node
length; text length
appendData (text); append text
deleteData (beginIndex, count); deleted text
insertData (beginIndex, text); text insertion
replaceData (beginIndex, count, text); replacement text
splitText (beiginIndex); beiginIndex position from the current text node into two text nodes
document.createTextNode (); create text node, the parameters to be inserted in a text node
substringData (beiginIndex, count); start count substrings extracted from beiginIndex
5, Comment (Note, as follows: <- annotation content -!>)