I'm wanting to get an image to display using innerHTML and I just can't seem to get it to work. It works fine with text and I'm trying to get it to display dynamically with other items inside innerHTML. Updated: the image is inside another element in the innerHTML. Image Example:
var div = document.createElement('div');
var image = document.createElement('img');
image.setAttribute('src', "https://picsum.photos/200/300");/*sample pic*/
div.innerHTML = '<a href="/"><h3>title</h3>'+ image + '</a>';
document.getElementById('block').appendChild(div);/*work fine if appendChild(image) or text inside innerHTML*/
<div id="block">
image
</div>