[英]Ajax loader image before actual image loads
My image hotel taking bit while as its trying to load large size image. 我的图片酒店在尝试加载大尺寸图片时花了点时间。 How can I set an Ajax Loader GIF image before the actual image loads to make my users understand to wait.
如何在实际图像加载之前设置Ajax Loader GIF图像,以使用户理解等待。 Thanks.
谢谢。
$(document).ready(function () {
window.showim = function(src) {
$("#imgLoader").attr("src", src);
};
});
JSFiddle: http://jsfiddle.net/52dY7/ JSFiddle: http : //jsfiddle.net/52dY7/
The simpliest way is to start with a loader image in the source of the targeted image. 最简单的方法是从目标图像的源中的加载器图像开始。
<img id="imgLoader" src="path/to/your/loader.gif" />
Look here... 看这里... http://jsfiddle.net/xflofoxx/52dY7/2/
http://jsfiddle.net/xflofoxx/52dY7/2/
$(document).ready(function () {
$('img').each(function() {
var $img = $(this),
origSrc = $img.attr('src');
$img.attr('src', '/path/to/loader/image');
$('<img />').on('load', function() {
$img.attr('src', origSrc);
}).attr('src', origSrc);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.