The difference between the core DOM and the HTML DOM

Source: Internet
Author: User

The DOM is divided into three parts:

(1) core dom: Traverse Dom tree, Add new node, Delete node, Modify node

(2) HTML dom: Accessing the DOM tree in an easy way

(3) XML DOM: quasi for manipulating XML documents


The difference between the core DOM and the HTML dom:

Core dom:

Object: document,node, Elementnode,textnode,attributenode,commentnode,nodelist


The core DOM provides a unified operating interface

CreateElement

AppendChild

SetAttribute

RemoveAttribute

NodeName

...


The core DOM creates a new element:

var newnode=document.createelement ("img")


To add an attribute to an element:

E.setattribure (",")

E.setAttriburenode (attr)


Applicable occasions:

The core DOM is suitable for manipulating nodes, such as creating, deleting, finding, etc.


HTML DOM:

Object: Image,table,form,input,select ... HTML Tag Object


Note: tablecell:td;tablerow:tr


HTML DOM provides a variety of encapsulated objects

Image

Select

Option

...


HTML DOM creates new elements

var newnode=new Image ();


To add an attribute to an element:

Img.src= ";

Img.id= ";

Imd.title= ";

Img.classname= "

img.style.display= ";

This is a typical HTML DOM method that will create elements and access the attributes of the Elements. these methods are simplified, and the attributes are directly treated as properties of the object, but we should pay attention to Img.classname= '


Applicable occasions:

HTML Dom is suitable for manipulating properties, such as reading or modifying the value of a property

The difference between the core DOM and the HTML DOM

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.