19
I'm just curious to know if there's a better solution for doing this:
var img = new Image();
var div = document.getElementById('foo');
img.onload = function() {
div.innerHTML += '<img src="'+img.src+'" />';
};
img.src = 'path/to/image.jpg';
Desired method:
console.log(img); // <img src="path/to/image.jpg" />
div.innerHTML += img;
Thoughts?