Definition and Usage..
The head property returns the head element of the current document.
Note: If there are more than one head element in the document, this property returns the first one.
Syntax: document.head
CODING:The head property returns the head element of the current document.
Note: If there are more than one head element in the document, this property returns the first one.
Syntax: document.head
<!DOCTYPE html>
<html>
<head id="myHead">
<title>My title</title>
</head>
<body>
<p>Click the button to display the id of the head element in the document.</p>
<button onclick="headId()">Display ID</button>
<p id="demo"></p>
<script>
function headId() {
var x = document.head.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<html>
<head id="myHead">
<title>My title</title>
</head>
<body>
<p>Click the button to display the id of the head element in the document.</p>
<button onclick="headId()">Display ID</button>
<p id="demo"></p>
<script>
function headId() {
var x = document.head.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
Comments
Post a Comment