Javascript-dom notes

Source: Internet
Author: User

Reference

JavaScript native DOM manipulation methods

JavaScript native DOM manipulation methods

First Category: node lookup related methods and properties

document/the parent node. getElementById ()
document/the parent node. getElementsByTagName ()
document/the parent node. getelementsbyname () //IE8 The following is not compatible

Called: Dom0-level method

. Gets the attributes of the element (common) getattribute ()
. Set the attributes of an element (common) setAttribute ()

In addition, the following methods are available in the DOM extension:

Queryselector ()
Queryselectorall ()
Matchesselector ()
The above method receives a CSS selector pair

Related references

Consider the related hierarchy relationship properties of whitespace characters
. Access child node properties DOM object. ChildNodes; Note that there are so-called "blank items" issues due to compatibility issues
Example:
var childnode = document.getElementsByTagName ("ul") [0].childnodes;

. Accessing the parent node parentnode

JavaScript DOM Object Common Properties

. innerHtml Dom object. innerHtml

. NodeType

. NodeName

. Offsetwidth offsetheight

. scorllheight

Document.documentElement.offsetWidth | | Document.body.offsetwidth;document.documentelement.offsetheight;

Class II: Dynamic Operation node related methods

. Create element node createelement () or document.createelement ()

. Create a text node createTextNode ()

. Add child node: parent element. appendchild ()

. Insert new node: parent element. insertbefore (Newnode,relnode)

. Replace node: parent element. replacechild (Newnode,oldnode)

. Delete node: parent element. removechild (node)

. Clone node: node. CloneNode () passed in true parameter represents deep clone, otherwise shallow clone

Javascript-dom notes

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.