Document head Property - Javascript DOM

Javascript examples for DOM:Document head

Description

The head property returns the <head> element of the current document.

Return Value

A reference to the Head Object, which represents a <head> element

The following code shows how to get the id of the <head> element of the current document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head id="myHead">
<title>My title</title>
</head>/*from  w ww .j  a v a2s.c om*/
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.head.id;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials