using innerhtml code example

Example 1: .innerhtml

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

Example 2: javascript innerhtml

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

Example 3: js innerHTML

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

Example 4: innerHTML

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

Example 5: execute js with innerhtml

<html>
<head>
 
<script>
function executer_script(monscript) {
    var head = document.getElementsByTagName("head")[0];
    var scr;
 
    var d = document.getElementById('resultat');
    d.innerHTML = monscript;
    var scrajx = d.getElementsByTagName('script');
 
    for(var i in scrajx) {
        scr = document.createElement("script");
        scr.type = "text/javascript";
        scr.text = scrajx[i].text;
        head.appendChild(scr);          
    }
}
</script>
 
</head>
<body>
 
<input type="button" value="test" onclick="executer_script('Mon html + du javascript <script>alert(\'test\');</script>');">
 
<div id="resultat"></div>
 
</body>
</html>