简体   繁体   English

通过Chrome控制台访问DOM

[英]Accessing the DOM via chrome console

Some questions regarding the DOM and what it exactly is. 有关DOM及其确切含义的一些问题。

When I access document via console.dir I get all the properties of document like this: 当我访问document通过console.dir我得到的所有属性document是这样的:

DOM JavaScript

When I do a console.log I get something which looks more like the DOM: 当我执行console.log我得到的东西看起来更像是DOM:

DOM JavaScript

Questions: 问题:

  1. In my understanding the second object which we get from console.log() is the DOM. 以我的理解,我们从console.log()获得的第二个对象是DOM。 and the one from console.dir() is the DOM and all the Javascript properties which exists on the DOM. console.dir()的一个是DOM和DOM上存在的所有Javascript属性。 Is this correct? 这个对吗?
  2. Is the DOM is a Javascript object? DOM是Javascript对象吗?
  3. Can we access the DOM structure of element nodes which we get from console.log(window.document) from a property of console.dir(window.document) ? 我们可以访问我们从中获取元素节点的DOM结构console.log(window.document)从属性console.dir(window.document)

The DOM (Document Object Model) is a generic term for a set of objects. DOM(文档对象模型)是一组对象的通用术语。

document is a DOM object; document是DOM对象; you're just seeing two different ways of representing it. 您只是看到两种不同的表示方式。

You can access the DOM hierarchy via properties like .children . 您可以通过.children属性访问DOM层次结构。

For more information, see the documentation . 有关更多信息,请参见文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM