jQuery Image Preloader


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.