display image using javascript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

display image using javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function imag(c,x) {//from ww  w  .  ja  v  a  2s.com
  var arr = [];
  for (var i = 0; i < x; i++) {
    arr.push(c);
  document.getElementById("demo").innerHTML = arr;
}
}

      </script> 
   </head> 
   <body> 
      <p>Click the button to add a new element to the array.</p> 
      <input type="number" id="myNumber" value=""> 
      <button onclick="imag('hello',5)">Try it</button> 
      <p id="demo"></p>  
   </body>
</html>

Related Tutorials