Issue
I'm curious as to why the element is replaced, rather than added at the end of the div...?
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript in Body</h1>
<div id="demo">
<h1>A paragraph will appear below</h1>
</div>
<button type="button" onclick='document.getElementById("demo").innerHTML = "<p>My First JavaScript</p>"'>Insert a paragraph</button>
</body>
</html>
Solution
You can replace =
with +=
to append innerHTML instead of replacing it.
Answered By - Valtteri Laitinen Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.