Js DOM Object

Source: Internet
Author: User

Dom

Dom Document Object Model documents it is primarily used to manipulate and access the properties and methods of each tag (tag) of a Web page

First clear:

???? 1. Use each tag in the HTML as an object in the DOM

???? 2. What are the attributes of the tag, then the object has

HTML document It has a certain level of relationship

HTML documents have only one

1. DOM node tree

Parent node

Child nodes

Sibling nodes they have a parent node at the same time

Text node

?

2. Node type

Document node root node

Element node Elements node

Attribute Node Properties node

Text node literal node

?

3. Dom classification

The core DOM is primarily manipulating HTML and XHTML to provide some properties and methods

HTML DOM is primarily manipulating HTML to provide some properties and methods

XML DOM is primarily manipulating XML

CSS DOM is mainly about manipulating CSS

The event DOM is primarily a manipulation of events

?

4. Core DOM operations 1, Common properties

NodeName node Name

FirstChild first child node

LastChild Last child node

ParentNode parent Node

ChildNodes List of child nodes it's actually a collection.

?

2, the operation of the label properties

Get Properties

The object you want to get. GetAttribute ("Property name")

?

Setting properties

SetAttribute ("Property name", "Property value")

?

Delete Property

RemoveAttribute ("Property name")

?

3, the operation of the label

1. Create a node (element)

???? Grammar:

???????? Document.createelement ("label name")

The return value is an element object

?

2. Adding nodes (elements)

Grammar:

The parent object. AppendChild (Element Object)

?

3. Deleting nodes

???? Grammar:

???????? Parent object. RemoveChild (child element Object)

?

5. Operation of HTML Dom

Because the core DOM is too cumbersome to manipulate HTML documents, then there is the HTML DOM

?

Document.getelemetbyid ("id attribute value")

Description

???? Get an object by the property value of the ID

This method only has the document

Returns a Label object gets what tag is what tag object

?

?

Parent object. getelementsbytagname ("tag name")

Description

???? This method it gets to is a collection even if you get only one it's also a collection

???? It accesses the same object name as the array element [subscript]

???? This method is owned by each parent object

?

Js DOM Object

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.