Javascript DOM HTML Document body Property change body html

Introduction

Change the HTML content of the current document:

document.body.innerHTML = "Some new HTML content";

Click the button to change the HTML content of the document.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from ww  w.  j  av  a2 s .c o  m*/
  document.body.innerHTML = "Some new HTML content";
}
</script>

</body>
</html>



PreviousNext

Related