Create an <img> element, assign src - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image


Create an <img> element, assign src

Demo Code

ResultView the demo in separate window

      <div id="destination"> 
         <!-- Destination Div --> 
  // Creates Image
  var image = document.createElement("img");
  // Sets Image Attributes
  image.src = "";
  image.width = "30";
  image.height = "30";
  // Adds Image to Body
   </body>/*from   ww w. ja  v  a2s.  c o m*/

Related Tutorials