I\'m trying to get the original width of an image with JQuery and make some adjustments in the CSS with a condition if an image is wider than 700px.
I used this code
Try it like this:
var img = new Image();
img.onload = function () {
var W2 = this.width;
if(W2 > 700) {
var photoHolder = document.getElementById("photoHolder");
photoHolder.style.verticalAlign = 'none';
photoHolder.style.textAlign = 'none';
}
}
img.src = document.getElementById('imageViewerImg').src;
Also, open the console and check for errors, check that you only have one element with that ID etc.