0
当我试图让图像的大小的话,我可以追加格的大小相同,解释图像。图像即将动态显示,因此如何获取浏览器中显示的图像大小而不是图像的实际大小。我已经尝试了以下代码,但在父类更小的图像时不起作用。获取动态图像的宽度
$('img').each(function(i) {
$currentImg = $(this);
imgTextshow = $currentImg.attr('imgtext');
var img = new Image();
img.onload = function() {
$currentImg.after("<div class='img-fscreen' style='width:" + this.width + "px; max-width:" + $currentImgParent + "'>" + imgTextshow + "</div>");
}
img.src = $(this).attr('src');
});
尝试使用 - 'this.naturalWidth' –
@vikrantsingh,OP是询问有关图像元素的宽度,浏览器呈现后.. – Rayon