Javascript Reference - HTML DOM HTML Object








The HTML object represents an HTML <html> element.

Standard Properties and Events

The HTML object supports the standard properties and events.

Example

We can access the <html> element by using getElementsByTagName().


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<!--  ww  w.ja v a  2 s  .  c  o m-->
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementsByTagName("HTML")[0].innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: