我正在使用表单输入来动态更改img标记的源。我想将ajax加载器放在图像的位置,直到图像下载完成,然后用新的图像替换加载器。有人知道我是怎么做到的吗?
发布于 2011-03-03 11:29:14
您不需要jQuery就能知道图像是什么时候加载的。
// show animation that indicates image is loading
var test = new Image();
test.onload = function () {
// this gets called when the image has loaded
// we need to place the image on the page:
$('#ImageContainerWhatever').append(test);
// and hide the loading animation
};
test.src = 'my_image.png';onload是在浏览器加载图片时调用的,不管是从web还是本地缓存。
请看这些示例:https://developer.mozilla.org/en/Canvas_tutorial/Using_images
发布于 2011-03-03 11:22:29
您可以在镜像的load事件中添加事件监听器。
https://stackoverflow.com/questions/5176289
复制相似问题