我有一个类为“userFeatureProductImage”的 div。这个 div 是重复的,但是偶尔可能会出现损坏的图像,所以我想隐藏 div 作为预防措施,如果发生这种情况。我该怎么做?
最佳答案
加载事件仅在图像有效时触发:
$('.userFeatureProductImage').hide();
$('.userFeatureProductImage img').load(function() {
$(this).closest('.userFeatureProductImage').show();
});
关于javascript - jquery/javascript - 如果包含图像损坏则隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4441211/