I have image URL's in a js file as objects.
How do I grab those images and insert them into the HTML dynamically?
I have tried using id's and getElementById but that didn't work.
I have image URL's in a js file as objects.
How do I grab those images and insert them into the HTML dynamically?
I have tried using id's and getElementById but that didn't work.
Fixed HTML (switched classes and IDs to make IDs unique) and added an image ID for simplicity:
<div id="msgStyle1" class="message">Waiting for image</div>
<div id="imgStyle1" class="message">
<img src="" id="image" />
</div>
JS:
document.getElementById('image').src = 'http://yourImagePathHere';
See it work here: http://jsfiddle.net/N3rCm/