码迷,mamicode.com
首页 > Web开发 > 详细

Preloading an Image with jQuery--reference

时间:2014-08-19 10:34:53      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:http   java   os   io   for   ar   2014   div   

Preloading images will make your application a bit faster by making it lightweight. It is very simple and easy to create and load DOM elements (in this case referring to images) with jQuery. If you want to preload images using jQuery there here is a detailed explanation on how you can do this:
• The foremost thing you need to do is create an image DOM element by providing a value for the src attribute for the image so that the web browser will know which image it has to load i.e. preloading the image. You can make use of the below code snippet for preloading an image using jQuery :

1
2
// Create an image DOM  element
var image1 = $(‘<img  />‘).attr(‘src‘, ‘link.jpg‘);

• Once you are done with creating the DOM image element you must insert this DOM image element inside the DOM tree by making use of any of the DOM manipulation methods. The most excellent method of doing this is to use the callback method so that it will insert the preloaded image directly into your application once it has completed loading.
• One more way is to make use of a jQuery plug-in to preload the image.

 

reference from:http://www.webdeveloperjuice.com/2014/08/06/preloading-an-image-with-jquery/

Preloading an Image with jQuery--reference,布布扣,bubuko.com

Preloading an Image with jQuery--reference

标签:http   java   os   io   for   ar   2014   div   

原文地址:http://www.cnblogs.com/davidwang456/p/3921285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!