how to change div content using javascript code example

Example 1: javascript set text of div

document.getElementById("content").innerHTML = "whatever";

Example 2: javascript replace content of div

document.getElementById("test").innerHTML = "new content"

Example 3: how to change text of div in javascript

document.getElementById("content").innerHTML = "whatever";

Example 4: javascript innerhtml

document.getElementById("example").innerHTML = "Paragraph changed!";

Example 5: js innerHTML

document.getElementById("Test").innerHTML = "<p style='color:red;'>Test</p>";

Tags:

Html Example