Change Inner HTML

Modify the HTML content of an element.

Preview

Code

<div id="box">Old content</div>

<button onclick="updateHTML()">Change HTML</button>

<script>
function updateHTML(){
  document.getElementById("box").innerHTML = "<strong>New HTML content</strong>";
}
</script>

More JS HTML DOM Examples (7)