innerHTML in js code example

Example 1: change text of element js

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: javascript innerhtml

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

Example 4: ~~ in javascript

~~ used to convert some types to int (32 bit int)

Example 5: js innerHTML

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

Example 6: innerHTML

document.getElementById("Test").innerHTML = "<h1>Test</h1>";