how to change html element using javascript code example

Example 1: change innerhtml

document.getElementById("p1").innerHTML = "New text!";

Example 2: .innerhtml

// .innerHTML method is used to change the html contents of a DOM object
document.getElementById("demo").innerHTML = "Paragraph changed!";

Example 3: change html element

element.innerHTML =  "<p>read this</p>"	Change the inner HTML of an element
element.style.color = "blue";			Change the style of an HTML element
element.setAttribute(important, "true")	Change the attribute value of an HTML element
element.important = "true"				Change the attribute value of an HTML element

Example 4: what is the meaning of the table innerhtml in javascript

table.innerhtml

Tags:

Php Example