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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -