我是从一个Ajax请求加载HTML,有的 IMG 标签吧。
I'm loading html from an ajax request, and some img tags in it.
我需要知道什么时候在AJAX图像加载满载调整大小的容器。 我不知道有多少图片都在,所以我不能简单地检查 .complete 值。
I need to know when the images loaded in the ajax are fully loaded to resize the container. I don't know how many images are in the result, so I can't simply check the .complete value.
你知道一个解决方案?
感谢您!
莱昂德罗
如果你正在使用jQuery,在 $(窗口).load()
命令可以设置一个函数被调用一次加载所有的图像,如下所示:
If you're using jQuery, the $(window).load()
command can set up a function to be called once all the images are loaded, as follows:
$(window).load(
function() {
// weave your magic here.
}
);
如果你不使用jQuery,我只是做时,我想我已经做了的小的其功能位:下载并检查源代码,看看它是怎么做的。那么这样做: - )
If you're not using jQuery, I'd just do what I've done when I want a little bit of its functionality: download it and examine the source to see how it does it. Then do that :-)