2

If I've multiple Image objects created like so:

var img0 = new Image();
var img1 = new Image();
var img2 = new Image();

What is the easiest and/or fastest way to wrap these into a jQuery object?

My current approach seems suboptimal:

var imgsJq = $(img0).add( $(img1) ).add( $(img2) );
4

2 回答 2

5
var imgsJq = $([img0, img1, img2]);
于 2013-05-20T14:23:37.503 回答
1

yours' is fine perfectly but if you want you can use the following as it looks simpler

 var $img = $(img0).add(img1).add(img2);

or you can use this also

 var $img = $([img0,img1,img2]);
于 2013-05-20T14:23:28.003 回答