I’m trying to figure out how to change the content in a div i’ve dynamically creating. This works fine if i’m trying to add text to the div, but adding an image doesn’t seem to work. There seems to be a syntax problem but i’m not sure what it is. Any ideas? Thanks in advance.
<script>
function divPic() {
document.getElementById('div1').innerHTML = "<img src='image1.jpg'>";
}
</script>
<div id="div1">
Click the link below to show a picture in this div.
</div>
<a href="#" onClick="divPic()">Show Picture in Div</a>