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

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

ruby - Net::HTTP extremely slow responses for HTTPS requests -

c++ - Boost Spirit Parser with a vector of three strings compiling into a struct, adapt not working -