Can someone assist me with a jQuery question regarding adding classes to images?
I am currently working on a DEMO on codepen.io
The issue I'm facing is that the JavaScript isn't adding a class to the image if the height is greater than the width. Is there anyone who can guide me in resolving this?
Below is the jQuery code I have been testing:
$(document).ready(function() {
var img = document.getElementById('.user_posted_image');
//or however you get a handle to the IMG
var width = img.clientWidth;
var height = img.clientHeight;
if(width < height){
$('img').addClass('portrait');
}
});