Create an image element and assign image source via Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Create an image element and assign image source via Element

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
var txt = {//from  w  ww . java2s  . co m
  "characters": [
    {"thumbn":"http://www.java2s.com/style/download.png"}
  ]
};
var img = document.createElement('img');
img.src = txt.characters[0].thumbn;
document.body.appendChild(img);

      </script>  
   </body>
</html>

Related Tutorials