gpt4 book ai didi

javascript - 有时 Jquery.width() 和 .height() 工作错误

转载 作者:太空宇宙 更新时间:2023-11-04 14:00:54 24 4
gpt4 key购买 nike

<分区>

我想循环播放所有 img(数百张图像)并且我想获取图像的宽度。但有时宽度和高度返回 0 或错误。

代码

$('img').each(function(){
var image = jQuery(this);
$(this).load(function(){
var width = img.width(), height=img.height();

//do something with width and height
})

})

我尝试使用 jquery.load 和 window.load 函数,但它们也是一样的。任何知道解决方案的人

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com