使用jquery更改!doctype

时间:2016-03-17 07:23:35

标签: javascript jquery html css html5

我想知道并理解,是否可以更改doctype? 我在google上浏览了很多关于它的内容,但是并没有明白这一点。

我正在使用基于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 doctype。 我想在那里问id我可以将旧的doctype更新为html5 doctype吗?

需要帮助。

谢谢,

1 个答案:

答案 0 :(得分:1)

https://developer.mozilla.org/en/document.doctype

  

doctype是一个只读属性

很遗憾,您无法修改doctype。

编辑:其实你可以。怪异。

var doctype = document.implementation.createDocumentType(
    'html',
    '',
    ''
);

document.doctype.parentNode.replaceChild(doctype, document.doctype);

让我知道这对你有用。