Difference: DOM Core and Html-dom [transfer from CSDN]

Source: Internet
Author: User

Today in the Reading JS DOM programming Art When you see the DOM Core and html-dom these 2 nouns, then online query, help record and understand;

The DOM (Document Object model) is a set of standards for accessing and manipulating XML (extensible Markup Language) documents developed by the consortium, the API. For example, the DOM tells the JavaScript engine how to display and manipulate XML-created markup (tag) in a browser window.

Dom is independent of specific platforms, browsers, and languages, and many languages implement DOM, as JavaScript and PHP implement DOM, so JavaScript has the getElementsByTagName () method, and PHP has The getElementsByTagName (), getElementsByTagName () method is the interface that the DOM prescribes to access an XML document.

XML is similar to HTML, but there is a difference between the two. Both XML and HTML come from SGML, and they all contain tags, with similar syntax, and the biggest difference between HTML and XML is that HTML is a trained markup language that describes and displays data with fixed tags, such as

Because of the similarities and differences between HTML and XML, JavaScript not only implements standard DOM methods and properties (i.e., created by the universe), but also implements HTML-specific DOM methods and properties, formerly known as Dom Core, and not specifically JavaScript. The latter is called Html-dom. Whether it's DOM core or html-dom, we should be aware of the compatibility between browsers when using JavaScript, because different browsers might not support these two types of methods and properties. DOM core and Html-dom, as well as cross-browser compatibility, are described in detail in the textbook. However, it is generally recommended to use the DOM core methods and properties, albeit slightly cumbersome.

the Common Core DOM methods are as follows :

1. Create a Node
CreateElement ()
createTextNode ()
2. Replication nodes
CloneNode ()
3. Inserting nodes
AppendChild ()
InsertBefore ()
4. Deleting nodes
RemoveChild ()
5. Replace node
ReplaceChild ()
6. Find and Set node properties
SetAttribute ()
GetAttribute ()
7. Find nodes
getElementById ()
getElementsByTagName ()
Haschildnode ()

the Common Core DOM properties are as follows :

Node.childnodes
Node.firstchild
Node.lastchild
Node.nextsibling
Node.previoussibling
Node.parentnode

[Transfer from csdn:http://blog.csdn.net/w11003060125/article/details/8549434]

Difference: DOM Core and Html-dom [go from csdn]

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.