Hi!
I'm trying to create a img tag dynamically with javascript. So far I've used the createElement function.
The problem is however that the created tag seems to be open:
Is there a way to create a self-closing img tag?
I would prefer not to use .innerHTML since I want the img to become part of the DOM tree (and looks cleaner )
I'm trying to create a img tag dynamically with javascript. So far I've used the createElement function.
The problem is however that the created tag seems to be open:
Code:
<img src="target">
Code:
<img src="target" />