Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the relationship between JavaScript and dom

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is the relationship between JavaScript and dom". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the relationship between JavaScript and dom".

Dom (document object Model) is a part of JavaScript, which provides JavaScript with methods and interfaces to deal with web content; all operations on web pages by JavaScript are done through DOM.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

A complete JavaScript consists of the following three parts:

ECMAScript: provides the syntax and basic objects of the language

Document object Model (DOM): provides methods and interfaces for dealing with web content

Browser object Model (BOM): provides methods and interfaces for interacting with browsers.

Document object Model (DOM):

DOM (document object Model) is the application program interface (API) of HTML and XML. DOM will plan the entire page into a document at a node level. Each part of a HTML or XML page is a derivative of a node.

DOM represents documents by creating trees, giving developers unprecedented control over the content and structure of documents. Nodes (getElementById, childNodes, appendChild, innerHTML) can be easily deleted, added, and replaced with DOM API.

The relationship between DOM and JavaScript

We all know that JavaScript is a programming language, and .js files are written in JavaScript, so what role does DOM play in it?

DOM is not a programming language, but there would be no web page operation without the DOM,JavaScript language. Everything we do to the web page with JavaScript is done through DOM.

The following code shows the difference between JavaScript and DOM more visually. The part of the code marked red is DOM:

Var Tags = document.getElementsByTagName ("a")

For (var I = 0; I < Tags.length; iTunes +)

{

Alert ("Href of this an element is:" + tags [I] .href + "\ n")

}

In this way, it can be clear at a glance which are the core JavaScript, which are DOM, and what their respective roles are. (the code is not explained here).

So there is an approximate equation:

Web or XML page = DOM + JS (scripting language)

Thank you for your reading, the above is the content of "what is the relationship between JavaScript and dom". After the study of this article, I believe you have a deeper understanding of what the relationship between JavaScript and dom is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report