【问题标题】:chrome console.log shows DOM instead of htmlchrome console.log 显示 DOM 而不是 html
【发布时间】:2014-08-27 03:59:19
【问题描述】:

我刚刚开始试用 chrome 开发者工具。根据chrome官方网站记录使用console.log的元素应该显示html,而console.dir应该在控制台上显示DOM。但是在我的系统上都显示 DOM。甚至console.dirxml 显示的是 DOM 而不是 html。这是一个已知问题吗?我该如何改变这种行为?

【问题讨论】:

  • 当我使用 console.log() 时,我看到了可扩展的 HTML 表示。您是否希望有一个 HTML 块?如果是这样,请使用element.outerHTML
  • 如果需要看html,需要将元素转成字符串stackoverflow.com/questions/1750815/…
  • 您能否发布一个指向“chrome 官方网站”的链接,说明“使用 console.log 记录元素应该显示 html”?这肯定是一个错误,因为 DOM 节点的日志记录行为已经很久没有改变了。

标签: javascript html google-chrome dom google-chrome-devtools


【解决方案1】:

如果您想记录元素的 HTML,只需使用 console.log(myElement.outerHTML)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 2017-11-10
    • 2020-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多