xxxxxxxxxx
// Get the element you want to modify
const element = document.getElementById('myElement');
// Set the inner HTML content
element.innerHTML = 'New HTML content';
xxxxxxxxxx
// .innerHTML method is used to change the html contents of a DOM object
document.getElementById("demo").innerHTML = "Paragraph changed!";
xxxxxxxxxx
document.getElementById("Test").innerHTML = "<p style='color:red;'>Test</p>";
xxxxxxxxxx
// Try to use `textContent` instead of innerHTML as innerHTML can be hacked.
document.getElementById("myHeader").textContent = "Heading"
xxxxxxxxxx
var out = document.getElementById("out");
var res = out.innerHTML;
res = "foo";
xxxxxxxxxx
// Get the element on which we want to set the innerHTML
const element = document.getElementById('elementId');
// Set the innerHTML of the element
element.innerHTML = 'New innerHTML value';