Home >Web Front-end >Front-end Q&A >What is the difference between dom and html dom

What is the difference between dom and html dom

WBOY
WBOYOriginal
2022-01-18 11:50:462850browse

Difference: 1. DOM is divided into three parts: core DOM, HTML DOM and XML DOM. Core DOM is used to traverse the DOM tree, and HTML DOM is used to access the DOM tree in a simple way; 2. Core DOM is suitable for operating nodes, and HTML DOM is suitable for operating attributes.

What is the difference between dom and html dom

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

What is the difference between dom and html dom

DOM is divided into three parts:

(1) Core DOM: Traverse the DOM tree, add new nodes, delete nodes, modify nodes

(2)HTML DOM: Access the DOM tree in a simple way

(3)XML DOM: Can be used for operations XML document

The difference between core dom and html dom

Core DOM:

Objects: Document, Node, ElementNode, TextNode, AttributeNode, CommentNode, NodeList

The core DOM provides a unified operation interface:

createElement

appendChild

setAttribute

removeAttribute

nodeName

Core DOM creates a new element:

var newNode=document.createElement("img")

Add attributes to the element:

e.setAttribure ('', '')

e.setAttribureNode(attr)

Applicable occasions:

Core DOM is suitable for operating nodes, such as creation, deletion, search, etc.

HTML DOM:

Objects: image, Table, Form, Input, Select...HTML tag objectification

HTML DOM provides various encapsulated Kind of object:

Image

Select

Option

HTML DOM Create new element:

var newNode=new Image();

Add attributes to elements:

img.src='';

img.id='';

imd.title='';

img.className=''

img.style.display='';

Applicable occasions:

HTML DOM is suitable for operating attributes, such as reading Get or modify the value of the attribute

Recommended tutorial: "html video tutorial"

The above is the detailed content of What is the difference between dom and html dom. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn