是否有一种方法,目标所有的img标签与0x0大小,并在jQuery中删除它们

Is there a way to target all img tags with 0x0 size and remove them in jQuery?

本文关键字:大小 并在 0x0 删除 标签 jQuery 一种 方法 是否 目标 img      更新时间:2023-09-26

我试图在我的应用程序中上传和删除图片,但有时当我删除我的图片时,它一直将其替换为高度和宽度为0的img。我想知道是否有一种方法可以使用jQuery来针对所有尺寸为0x0的图像并仅删除它们。

var img = $('#imageid'); 
var width = img.width();
var height = img.height();

是在浏览器中看到的图像的尺寸,因为.width();.height();返回DOM属性,我猜。

可能:

$("img").filter(function() {
    return $(this).height() == 0 && $(this).width() == 0;
}).remove();