Document body Property - Change the HTML content of the current document and overwrite all existing HTML elements inside <body> - Javascript DOM

Javascript examples for DOM:Document body

Description

Document body Property - Change the HTML content of the current document and overwrite all existing HTML elements inside <body>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

<script>
function myFunction() {/*w ww .  ja va 2 s. com*/
    document.body.innerHTML = "Some new HTML content";
}
</script>

</body>
</html>

Related Tutorials