选择高度大于给定高度的所有元素

时间:2012-11-20 16:34:42

标签: javascript jquery css height

如何选择高度大于200px的物品,并在var。

中记住它们
var something = $('.myClass').withHeightMoreThan200px();
$('.myClass').each(function(){$(this).height(random(50,500)});
something.hide(); //even if after random change of height some new elements have now height >200px I want it to affect only those remembered before.

1 个答案:

答案 0 :(得分:8)

使用filter()

var something = $('.myClass').filter(function(){
    return $(this).height() > 200;
});