×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
1
Language: Javascript
Posted by: Tony Perea
Added: Jul 13, 2012 3:57 AM
Views: 75
Image preload with JQuery
  1. //SINGLE IMAGE
  2. var image = $('<img />').attr('src', '/path/to/image.png');
  3.  
  4. //FOR MULTIPLE IMAGES
  5. var images = [
  6.         '/path/to/image1.png',
  7.         '/path/to/image2.png'
  8. ];
  9.  
  10. $(images).each(function() {
  11.         var image = $('<img />').attr('src', this);
  12. });