jQuery图像预加载程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

以上是关于jQuery图像预加载程序的主要内容,如果未能解决你的问题,请参考以下文章