Getting Started with DOM methods-lesson Two

Source: Internet
Author: User

1, Console.log () is the bar element displayed in the console
2, AppendChild () is to append the element to the end
3. innerHTML gets all the content inside the element including the child elements inside it.
4. innertext gets the text inside the element, excluding child elements
5, GetElement is to get existing elements
6, CreateElement is created element, does not exist, dynamically created
7, ParentNode parent node,
8, removechild () Delete child nodes
9, Getattribue () Gets the property, variable. getattribute (attribute)
10, SetAttribute () set properties, SetAttribute ("Property name", "Property value")

Explanation:

The ① appendchild () method adds the last child node to the node.

Tip: If you need to create a new paragraph that contains text, remember to add the text node to the text of the paragraph, and then add the paragraph to the document.

You can also use the AppendChild () method to move elements from one element to another.

The ② ParentNode property returns the parent node of the specified node as a nodes object.

If the specified node does not have a parent node, NULL is returned.

The ③ getattribute () method returns the property value for the specified property name.

Tip: If you want to return properties as Attr objects, use GetAttributeNode.

The ④ SetAttribute () method adds the specified property and assigns the specified value to it.

If the specified property already exists, only the value is set/changed.

Getting Started with DOM methods-lesson Two

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.