I am trying to accomplish something like this :
<?php $url = 'http://www.mydomain.com/img/picture.jpg'; ?>
<img src='<?php echo $url ?>' />
Only the problem is I want to accomplish this using javascript. Something like this
<script>url = 'http://www.mydomain.com/img/picture.jpg'</script>
<img src='<script>document.write(url)</script>' />
Of course it wouldn't work, but you got the idea. Any thought ?
Try - http://jsfiddle.net/m2Prh/
<img id="image" />
<script>
var url = 'http://lorempixel.com/300/200';
document.getElementById("image").src = url;
</script>
I suggest reading jquery ,you can acesss every html element