JS HTML

HOW TO ADD HTML CODE IN JAVASCRIPT

TARGET ELEMENT <p id="para">FOO</p>

INNER HTML

01

GET HTML ELEMENT var p = document.getElementById("para"); REPLACE "FOO" WITH "DOO" p.innerHTML = "DOO";   TO APPEND p.innerHTML += "<strong>ZOO</strong>";

TARGET ELEMENT <p id="para">FOO</p>

CREATE ELEMENT

02

CREATE NEW ELEMENT let s = document.createElement("strong"); stronk.innerHTML = "ZOO"; GET TARGET var p = document.getElementById("para");   APPEND NEW ELEMENT p.appendChild(s);