是jQuery的ATTR()异步? [英] Is jquery's attr() asynchronous?

查看:362
本文介绍了是jQuery的ATTR()异步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个循环,在每个迭代追加与img标签的div,然后用像这样加载其src属性:

Say I have a loop that on each iteration it appends a div with an img tag, then loads its src attribute using something like this:

$("img").last().attr('src', imageSource);

如果我这样做了一些不同的图像几次迭代,我收到这些图像的异步加载?

If I'm doing this for a few iterations for a few different images, am I getting an asynchronous loading of those images?

如果不是,我怎么异步通过循环加载图像?我会很高兴得到一些AJAX技巧。

If not, how do I load images asynchronously by looping? I'll be happy to get some ajax tips.

推荐答案

ATTR 不是异步的。这是一个非常简单的操作,发生瞬间有效

attr is not asynchronous. It is a very simple operation that takes place effectively instantly.

然而,来自服务器的图像的装载花费相当长。这个过程的的异步:只要你设定的属性,你可以忘掉它,浏览器将加载图像,你的背景

However, the loading of the images from the server takes rather longer. That process is asynchronous: as soon as you set the attribute, you can forget about it and the browser will load the image for you in the background.

加载图像异步是不是一种选择:它实际上是图像加载的唯一途径。

Loading images asynchronously isn't an option: it is in fact the only way that images are loaded.

这篇关于是jQuery的ATTR()异步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆