Fire event if image is finished loading - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:attr

Description

Fire event if image is finished loading

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(function(){//ww w . java 2  s.c om
$('#myimage').attr('src', 'http://www.java2s.com/style/demo/Firefox.png').load(function() {
   console.log('loaded!');
});;
    });

      </script> 
 </head> 
 <body> 
  <img id="myimage" src="http://www.java2s.com/style/demo/Firefox.png">  
 </body>
</html>

Related Tutorials