2012-01-19 19 views

回答

6

這應做到:

if ($('.banner-image:empty').length) { 
    $('#banner-wrapper').css({'height' : '210px'}); 
}; 

要檢查是否有在div沒有圖像做到這一點:

if ($('.banner-image img').length === 0) { 
    $('#banner-wrapper').css({'height' : '210px'}); 
}; 
+0

只有在DIV中沒有空格的情況下,這纔有效。無論如何,只有當div中沒有​​img時才能使用它。 – Guy

+0

@Guy是的,檢查我的編輯 –

+0

非常感謝。 – Guy

0
if(!$('.banner-image').html().length) { 
    $('#banner-wrapper').css({'height' : '210px'}); 
}; 

這應該做的伎倆。

0
if ($('.banner-image:empty').size()) { 
    $('#banner-wrapper').css({'height' : '210px'}); 
}; 
0

好了,如果沒有其他人要發佈它:

if (!$('.banner-image').find('img').length) { // no images inside .banner-image 
    $('#banner-wrapper').css({'height' : '210px'}); 
}; 
相關問題