Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
HTML DOM HTML Object
The HTML Object represents the element of an HTML document.
Let us see how to access HTML object −
Syntax
Following is the syntax −
document.getElementsByTagName(“HTML”)
Let us see an example of HTML object −
Example
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
}
.btn{
background-color:lightblue;
border:none;
height:2rem;
border-radius:50px;
width:60%;
margin:1rem auto;
}
.show{
font-size:1rem;
font-weight:bold;
color:orange;
border:2px solid green;
padding:10px;
display:none;
}
</style>
</head>
<body>
<h1>DOM HTML Object Example</h1>
<button type="button" onclick="getContent()" class="btn">Click me to get content
inside HTML tag</button>
<div class="show"></div>
<script>
function getContent(){
var content=document.getElementsByTagName("HTML")[0].innerHTML;
document.querySelector(".show").innerHTML = content;
document.querySelector(".show").style.display ="block";
}
</script>
</body>
</html>
Output
This will produce the following output −

Click on “blue” button to get all content inside this page tag −

Advertisements
