The doctype
property gets the doctype of the HTML
document, as a DocumentType object.
doctype |
Yes | Yes | Yes | Yes | Yes |
document.doctype
The document's doctype, as a DocumentType object.
The following code shows how to get the doctype object of an HTML document.
<!DOCTYPE html>
<html>
<body>
<p id="demo">doctype name.</p>
<button onclick="myFunction()">test</button>
<!-- www. ja va 2s. co m-->
<script>
function myFunction()
{
var x=document.getElementById("demo");
x.innerHTML=document.doctype.name;
}
</script>
</body>
</html>
The code above is rendered as follows: