jQuery DOM 更改未出现在视图源中 [英] jQuery DOM changes not appearing in view source

查看:23
本文介绍了jQuery DOM 更改未出现在视图源中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题.我知道使用 jQuery,您可以通过执行诸如

I have a simple question here. I know with jQuery you can dynamically append HTML elements in the DOM by doing stuff like

$('').append('<p>Test</p>');

但我的问题是,为什么这些元素实际上没有出现在代码中(例如,当您在浏览器中查看源代码时).

But my question is, why don't these elements actually appear visually in the code (when you View Source in your browser for example).

请专家告诉我原因.谢谢

Please experts, let me know why. Thanks

推荐答案

原始来源永远不会改变.只有 DOM 发生了变化.

The original source never changes. Only the DOM changes.

您可以使用浏览器的开发人员工具查看 DOM 更改的 HTML 可视化.

You can see an HTML visualization of DOM changes using your browser's developer tools.

您应该知道,当您操作 DOM 时,您绝不会操作 HTML.开发人员工具提供的 HTML 可视化是对 DOM 当前状态的解释.没有对 HTML 标记进行实际修改.

You should be aware that when you manipulate the DOM, you're never manipulating HTML. The HTML visualization offered by the developer tools is an interpretation of the current state of the DOM. There's no actual modification of HTML markup.

这篇关于jQuery DOM 更改未出现在视图源中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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