innerHTML removes closing slash for an image tag

Viewed 86

I created an example where you can see the issue.

window.onload = function () { 
        console.log(document.getElementById("container").innerHTML)
};
<div id="container">
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1200px-Image_created_with_a_mobile_phone.png" />
</div>

<div id="tree"></div>

The result you can see in alert. When I use innerHTML the closing slash of img tag dissapeares for some reason. How can I get a valid result with the slash in the end?

0 Answers
Related