我有以下代码,循环获取表中的所有图像,然后将它们追加到#featured
然后将其附加到#wrapper
。问题是在所有东西都附加到#wrapper
之后,图像没有尺寸,因此没有显示尺寸。这就像图像的宽度和高度为0px。我如何克服这个大小问题。jQuery没有图像尺寸后追加
var featured = '<div id="featured"></div>';
$('#imageTable tbody tr td img').each(function(){
$(featured).append('<img src='+$(this).attr("src")+' />');
});
$(featured).appendTo('#wrapper');
我试图做
$(featured).load(function(){
$(this).appendTo('#wrapper');
});
来解决这个问题,但不起作用。
运行此代码时是否加载了图像? – alex