2012-11-20 126 views
4

如何選擇高度大於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. 

回答

8

使用filter()

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