Get HTML Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:HTML

Introduction

The HTML object represents an HTML <html> element.

You can access the <html> element by using getElementsByTagName():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">get the HTML content of the html element</button>

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

<script>
function myFunction() {//from   w  ww.j a  va 2s . co m
    var x = document.getElementsByTagName("HTML")[0].innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials