我想知道并了解,是否可以更改文档类型? 我在谷歌上浏览了很多关于它的内容,但没有弄清楚这一点。
我在基于 CMS 的布局中工作,我没有多余的 html 代码。我可以修改 CSS 并添加脚本来添加 div 和其他 html 元素。
我们在 html 编码中使用旧的 doctype。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
因此我无法处理最新的 html5 文档类型。 无论如何我想在那里问 id 我可以将旧的 doctype 更新为 html5 doctype 吗?
需要帮助。
谢谢,
最佳答案
https://developer.mozilla.org/en/document.doctype
doctype is a read-only property
很遗憾,您无法修改文档类型。
编辑:实际上你可以。很奇怪。
var doctype = document.implementation.createDocumentType(
'html',
'',
''
);
document.doctype.parentNode.replaceChild(doctype, document.doctype);
让我知道你的结果如何。
关于javascript - 用 jquery 改变 !doctype,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36053988/