Loop through class with if statement
Hi all,
I have multiple divs with class .repository_image all containing an image. I need to loop through them and assign the class .portrait if it contains an image that is in portrait orientation.
I tried the following but it did not work :(
- $('.repository_image').each(function(){
- if($(this).width() < $(this).height()){
- $(this).addClass("portrait");
- }
- });
What am I doing wrong?