Javascript learning journey (2) _ basic knowledge

Source: Internet
Author: User
DOM is the initial abbreviation of "DocumentObjectModel" (Document Object Model. Chapter 3 DOM

DOM is the abbreviation of "Document Object Model" (Document Object Model.

Node

Element node: it is the DOM atom. For example, the name of a text paragraph element is the name of the p unordered list element ul... [the attribute value of nodeType is 1]

Text node: a text node is always contained within an element node. [The value of nodeType is 3]

Attribute node: attribute nodes are always placed in the start label. For example, title = "a gentle reminder" [the value of nodeType is 2]



The getElementById () method returns an object.



Document. getElementById (id) id must be placed in single or double quotation marks, for example, document. getElementById ("purchases ")



The getElementsByTagName () method returns an array of objects.



The getElementsByTagName (tag) tag must be the name of the (x) html tag and placed in double quotation marks, for example, document. getElementsByTagName ("li ")







The getAttribute () method queries attributes by calling specific objects.



Object. getAttribute (attribute)



SetAttribute () method to set attributes



Object. setAttribute (attribute, value)
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.