0
The JS code below adds an extra paragraph to the HTML page on click of a button. But how can I change this code to add an image
function newParagraph() { var element = document.createElement("p"); var main = document.getElementById("main"); main.appendChild(element); var text = document.createTextNode("The Battle of Salamis was fought between an alliance of Greek cities and the Persian Empire in 480 BC. The Greeks decisively defeated the Persian navy."); element.appendChild(text); }
3 Réponses
+ 1
ok. Will I still have to create new element ? as in : var element = document.createElement("IMG"); ?
0
Peter Claver uhh why did you delete your answer ?
0
Masquerade I'm getting you the exact thing