jQuery如果高度

iKa*_*ars 1 each jquery if-statement

我有几个div与类"priceText",我试图实现,如果div.priceText高度小于100px,比隐藏这个 div中的图像.

我不能让这个工作.我已经设法隐藏所有图像上的所有 .priceText divs.其中一个.priceText div中的IF高度小于100px,但我需要隐藏那个图像女巫在这个div中小于100px.

所以我未完成的代码:

$(".priceText").each(function() {

var $minHeight = 100;
var $priceHeight = $('.priceText').height();

if ( $priceHeight < $minHeight) {
$("img", this).remove();
}

});
Run Code Online (Sandbox Code Playgroud)

Nic*_*tti 7

我会做:

$(".priceText").each(function() {

var $minHeight = 100;
//you need the height of the div you are currently iterating on: use this
if ( $(this).height() < $minHeight) {
//find the img in this div and hide it
$(this).find('img').remove();
}

});
Run Code Online (Sandbox Code Playgroud)