Create <img> element and set image src - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


Create <img> element and set image src

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from w  ww .j a  v a  2 s . c o m
    var myanim = new Image();
    myanim.src = '';
    myanim.onload = function() {
        document.getElementById('anim').src = myanim.src;

      <img id="anim" src="">  

Related Tutorials