Changing IinnerHTML

This fiddle shows how to change the HTML associated with specific IDs.

by Brian von Konsky

HTML

<p id="p1">
   Nothing here
</p>
<p id="p2">
   Here either
</p>
<button onclick="function1()">Button 1</button>
<button onclick="function2()">Button 2</button>

JavaScript

function function1() {
   document.getElementById("p1").innerHTML="p1 changed";
}

function function2() {
   document.getElementById("p2").innerHTML="p2 changed";
}