javascript - Jquery addClass ONLY to div with class which is really higher -
var n = $('.class'); var height = n.height(); if (height > 200) n.addclass('padding'); });
the code above causes divs class padding including these divs not higher 200, need add padding elements, bigger 200. rest have stay without padding. knows how can it?
use .filter
select elements height want:
$(".class").filter(function() { return $(this).height() > 200; }).addclass("padding");
in code, n.height()
returns height of first element selected, doesn't change n
refers in n.addclass()
call.
Comments
Post a Comment