0
我有问题的宽度和高度。宽度和高度undefined - Javascript/jQuery
我的功能:
function testImageSize(testSrc) {
var imageTestLink = "";
var link = testSrc.attr("src");
link = link.replace("/thumbs/", "/images/");
imageTestLink = link.replace(".thumb", "");
var theImage = new Image();
theImage.src = imageTestLink;
console.log(imageTestLink);
var rw = theImage.width;
var rh = theImage.height;
console.log(rw, rh);
}
我的问题是,当我运行这个功能imagesTestLink
总是返回正确的链接到图像。但是rw
和rh
有时会在控制台中返回0 0
值。有人可以帮我解决这个问题吗?我已经阅读了很多主题,但我没有找到我的答案。
问候, Fantazy