IMG SRC tags and JavaScript

Nope. It’s not possible, at least not in all browsers. You can do something like this instead:

<img src="https://stackoverflow.com/questions/116967/blank.png" id="image" alt="just nothing">
<script type="text/javascript">
    document.getElementById('image').src = "yourpicture.png";
</script>

Your favourite JavaScript framework will provide nicer ways 🙂

Leave a Comment