开发者

Validate HTML code created by jQuery

I have an HTML page, by clicking elements li开发者_StackOverflowke 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 ?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜