Show Preloader while loading Images with JQuery


/ Published in: jQuery
Save to your folder(s)

Thank you marcg for posting this on Snipplr http://stackoverflow.com/questions/1379994/detect-when-a-specific-image-has-finished-loading


Copy this code and paste it in your HTML
  1. <script>
  2. $(function () {
  3. var img = new Image();
  4. $(img).load(function () {
  5. $(this).hide();
  6. $('#loader').removeClass('loading').append(this);
  7. $(this).fadeIn();
  8. }).error(function () {
  9. // notify the user that the image could not be loaded
  10. }).attr('src', 'http://farm3.static.flickr.com/2405/2238919394_4c9b5aa921_o.jpg');
  11. });
  12. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.