Posted By

iqwebdev on 07/14/10


Tagged

image


Versions (?)

Who likes this?

8 people have marked this snippet as a favorite

jackkeller
legacye
dhollifield
fenta23
jearley
Ch_Sch
agdm
ringo380


jQuery Image Preloader


 / Published in: jQuery
 

Very easy way to preload images which are needed later (e.g. when a hover is performed)

  1. <script type="text/javascript">
  2. $.preloadImages = function()
  3. {
  4. for(var i = 0; i<arguments.length; i++)
  5. {
  6. $("<img />").attr("src", arguments[i]);
  7. }
  8. }
  9.  
  10. $(document).ready(function()
  11. {
  12. $.preloadImages("hoverimage1.jpg","hoverimage2.jpg");
  13. });
  14. </script>

Report this snippet  

You need to login to post a comment.