load images on demand in web page - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

load images on demand in web page

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <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 .  com
function click_to_load() {
    document.getElementById("image").src = "http://www.java2s.com/style/download.png";
}
document.getElementById("button").onclick = click_to_load;
    }

      </script> 
   </head> 
   <body> 
      <button id="button">
         load 
         <img id="image">  
      </button>
   </body>
</html>

Related Tutorials