I have 4 divs with images inside them and I need to add a class property depending on the img width and height.
Here's an example code to explain what I need to do. (Obviously, this code doesn't work)
function cropImg(){
var imgs = document.getElementsByClassName(".prodImg");
for(i in imgs){
var imgWidth = imgs[i].naturalWidth;
var imgHeight = imgs[i].naturalHeight;
if(imgWidth>imgHeight){
imgs[i].css({
"max-height": "100%"
});
}else{
imgs[i].css({
"max-width": "100%"
});
}
}
}
I really appreciate your help.