Reputation: 264
How can I know in jQuery the height of an image loaded with:
style="width:100%; height: auto;"
The width screen in mobile device is ever different, and i dont like the effect "jump" when the page is loading. I hope I was clear. Thanks
Upvotes: 0
Views: 74
Reputation: 2725
try following (see if it helps :) ):
alert("width: " + $("#imgRandom").width() +"\nHeight: "+$("#imgRandom").height() );
fiddle link: http://jsfiddle.net/6dnSM/
i hope it helps.
Upvotes: 1
Reputation: 53198
You can quite easily get the height using height()
and outerHeight()
, for example:
var imgHeight = $('img.image-class').height();
Or:
var imgHeight = $('img.image-class').outerHeight(false); // the argument indicates whether to include the margin
Upvotes: 0