验证 jQuery 创建的 HTML 代码
我有一个 HTML 页面,通过单击按钮等元素,新的 DOM 元素将使用 jQuery 附加到我的文档中(即 $('#foo').append('
)。我还使用 remove()
删除 DOM 元素。
我知道 validator 可以验证我的 HTML 代码。但我还需要验证使用 jQuery 创建的 HTML 代码。我怎样才能做到这一点?例如,我想单击
一个按钮,查看更改后的HTML代码并验证它等等...
我尝试使用Inspect Element
显示“实时”HTML代码。但是,在复制代码时,它不会复制反斜杠 (/
),因此当将粘贴的文档使用到验证器时,我会收到大量错误,提示缺少 /
像这样:
Line 2, Column 69: end tag for "meta" omitted, but OMITTAG NO was specified
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
虽然我真正的源代码包含:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
关于做什么的任何想法?
I have an HTML page, by clicking elements like buttons new DOM elements are appended to my document using jQuery (i.e. $('#foo').append('<div> ... </div>');
). I also remove DOM elements using remove()
.
I'm aware of validator in order to validate my HTML code. But I need to validate also the HTML code created using jQuery. How can I do that? For example I would like to click
a button, see the changed HTML code and validate it and so on ...
I tried using Inspect Element
which shows "live" HTML code. But when copying the code it doesn't copy the backslash (/
), so when using the pasted document to the validator I get a ton of errors saying that /
is missing like this one:
Line 2, Column 69: end tag for "meta" omitted, but OMITTAG NO was specified
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
Although my real source code contains:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Any ideas on what to do ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试浏览器扩展。大致如下:
Chrome:
https://chrome.google.com/webstore/detail/ cgndfbhngibokieehnjhbjkkhbfmhojo
火狐:
https://addons.mozilla.org/en-US/firefox/addon/ Total-validator/
我不太使用 IE 或 Safari,所以我无法帮助你。
我唯一能想到的另一件事是使用 jQuery 在控制台中执行类似
$('html').html()
的操作,并将结果复制到文本文件中。我确信这将包括 DOM 修改I would try a browser extension. Something along the lines of this:
Chrome:
https://chrome.google.com/webstore/detail/cgndfbhngibokieehnjhbjkkhbfmhojo
Firefox:
https://addons.mozilla.org/en-US/firefox/addon/total-validator/
I do not use IE or Safari much, so I couldn't help you there.
The only other thing I could think of to try is using jQuery to do something like
$('html').html()
in your console and copy the result to a text file. I know for sure this will include DOM modifications