Document body Property - Get the HTML content of the current document: - Javascript DOM

Javascript examples for DOM:Document body

Description

Document body Property - Get the HTML content of the current document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {/*w  w w .j  a  va2  s  .  c o  m*/
    var x = document.body.innerHTML;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials