javascript - "double quotes"在chrome中是什么意思? (这很奇怪)

标签 javascript jquery html google-chrome

我注意到 Google Chrome 将元素的内部文本括在双引号中,但是,Html() Jquery 函数返回不带引号的字符串。这是为什么?

这里有一些实验:

HTML 代码:

<p id="simple-text">This is a simple paragraph .</p>

<p id="lorem-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p id="span-text">This is a simple <span>span element</span> paragraph .</p>

Chrome 中的结果(元素):

Elements

注意:简单文本(#simple-text)中没有双引号

使用 Jquery(控制台)在 Chrome 中的结果:

Jquery

注意:跨度文本 (#span-text) 中没有双引号

更新(编辑 Html):

enter image description here

enter image description here

我可以说有三个元素:字符串、跨度和字符串吗?

最佳答案

引号实际上并不是 DOM 的一部分,它只是 DevTools 中的一个 UX 功能,用于指示它是您正在查看的字符串。

enter image description here

如果右键单击该元素并选择编辑 HTML,您将看到原始 HTML。

enter image description here

关于javascript - "double quotes"在chrome中是什么意思? (这很奇怪),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49390905/

相关文章:

javascript - 使用 jquery(或 javascript)拦截仅点击 "clickable"元素

javascript - D3.js折线图: axis with fixed position

php - 具有两个规则的数据表表顺序

javascript - jQuery 验证至少选择一个复选框

javascript - 如何使用 jQuery 检查图像是否加载?

javascript - 如何调整 HTML 页面中单个元素的大小,以便其余元素适合窗口而不滚动?

java - 如何在输入流中找到什么?

html - 使用 CSS 将 div 设置为剩余高度,上面和下面的高度 div 未知

javascript - 在单页应用程序中处理文本编辑器的 Ctrl+Z(撤消/重做)

javascript - JQuery 通过键从 json 中获取值