DOM,raw html和页面上显示的是什么关系? [英] What is the relationship been the DOM, raw html, and what is display on the page?

查看:203
本文介绍了DOM,raw html和页面上显示的是什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的理解中,DOM是HTML的面向对象表示。如果这是准确的,这意味着在任何给定的网页中基本上有三个层次的抽象:


  1. Javascript表示(DOM) li>
  2. 原始HTML

  3. 向用户显示的实际页面

所有这些级别之间的关系是什么?



更具体地说,


如何影响DOM(通过vanilla Javascript)影响
显示页面? Javascript是否直接影响显示?或者JS
只会影响DOM和显示页面的更改以反映DOM?



解决方案

Dom是浏览器解析的HTML。



此处



  1. DOM是一个具有关联API的文档模型,用于操作它


  2. HTML是一种标记语言,可让您在文本中表示某种DOM。


  3. 文档对象模型(DOM)是一种语言无关模型,由代表文档结构的对象组成。





以及DOM和HTML之间的关系



  1. DOM是用于表示HTML的树模型,其中html的每个元素作为树的一个节点。



    5什么时候DOM不同于HTML?


这有一种可能性:您的HTML中有错误,
浏览器已为您修复。假设您的HTML中有一个< table> 元素
,并省略所需的< tbody> 元素。浏览器
将为您插入< tbody> 。它将在DOM中,
,所以你可以使用JavaScript找到它,并使用CSS,
进行风格,即使它不在你的HTML中。


还阅读 this



  1. 受javascript的影响:javascript由浏览器解释,javascript的任何更改都不在DOM上,而不是
    html。



From my understanding the DOM is an object oriented representation of the HTML. If that is accurate than it would mean there are essentially three levels of abstraction in any given web page:

  1. Javascript representation (DOM)
  2. Raw HTML
  3. Actual page displayed to user

What is the relationship between all these levels?

More specifically,

How does effecting the DOM (through vanilla Javascript) effect the display page? Does Javascript effect the display directly? Or does JS only effect the DOM and the display page changes to reflect the DOM?

解决方案

Dom is the html parsed by the browser.

from here

  1. DOM is a model of a document with an associated API for manipulating it.

  2. HTML is a markup language that lets you represent a certain kind of DOM in text.

  3. The Document Object Model (DOM) is a language-independent model made up of objects representing the structure of a document

and for the relationship between DOM and HTML

  1. DOM is the tree model to represent HTML where each element from html acts as a node of the tree.

    5 When is the DOM different than the HTML?

Here's one possibility: there are mistakes in your HTML and the browser has fixed them for you. Let's say you have a <table> element in your HTML and leave out the required <tbody> element. The browser will just insert that <tbody> for you. It will be there in the DOM, so you'll be able to find it with JavaScript and style it with CSS, even though it's not in your HTML.

also read this and this

  1. what is affected by javascript: javascript is interpreted by browsers and any change which javascript performs is on DOM not on html.

这篇关于DOM,raw html和页面上显示的是什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆