Preloading an Image with jQuery--reference
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 alt="" />').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/
相关文章
- JQuery基础--事件
- jQuery分页插件(jquery.page.js)的使用
- [JQuery] jQuery选择器ID、CLASS、标签获取对象值、属性、设置css样式
- 【Python成长之路】从 零做网站开发 -- 基于Flask和JQuery,实现表格管理平台
- jquery实现的个性网站首页 详细信息
- jQuery 2.0.3 源码分析 Deferred概念
- 第一百九十节,jQuery,编辑器插件
- 第一百八十七节,jQuery,知问前端--cookie 插件,注册成功后生成cookie,显示登录状态
- 第一百七十七节,jQuery,知问前端--概述及 jQuery UI
- jQuery的类数组对象结构(转)
- [CoffeeScript] Level 2: jQuery to CoffeeScript -- Ex
- 电子签章盖章之jQuery插件jquery.zsign
- jQuery 选择表格(table)里的行和列[转]
- iframe中的jquery ui modal dialog 覆盖父窗口
- Jquery N级联动 json/xml
- jQuery Custom Selector JQuery自定义选择器
- JQuery模板插件-jquery.tmpl
- 电子签章盖章之jQuery插件jquery.zsign
- jQuery easyUI--accordion折叠面板
- jQuery easyUI--消息框的使用
- HTML+CSS+jquery代码实例:水波纹效果与纯HTML CSS和jquery(拿来就能用)
- javascript arguments对象研究--针对jquery源码研究再研究
- 【Python成长之路】从 零做网站开发 -- 基于Flask和JQuery,实现表格管理平台
- JQuery实战--能够编辑的表格
- jQuery--对话框插件--dialog
- jquery-data的三种用法
- jQuery.Validate自定义规程的使用案例
- jquery ajax 跨域设置