预加载图像

 如果你的网页要使用大量开始不可见的(例如,悬停的)图像,那么可以预加载这些图像:

$.preloadImages = function () {
  for (var i = 0; i < arguments.length; i++) {
    $('<img>').attr('src', arguments[i]);
  }
};

$.preloadImages('img/hover-on.png', 'img/hover-off.png');

or

$(document).ready(function() {
jQuery.preloadImages = function()
{
  for(var i = 0; i<ARGUMENTS.LENGTH; jQuery(?<img { i++)>").attr("src", arguments[i]);
  }
}
// how to use
$.preloadImages("image1.jpg");
});

 

posted @ 2016-01-12 16:06  侠岚之弋痕夕  阅读(148)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!