Is it possible, via jQuery, to get the height of an background-image? The height in pixel? And if so, how to? I'm creating an lightbox, so i need the height to match the photos actual height exactly.
Thank you.
- Magnus Pilegaard
Is it possible, via jQuery, to get the height of an background-image? The height in pixel? And if so, how to? I'm creating an lightbox, so i need the height to match the photos actual height exactly.
Thank you.
I'm not sure whether you mean the height of the actual browser window which has a background image or the height of the image file used for the background. I'll try and help with both.
Height of browser window:
var height = $(window).height();
or
var height = $(document).height();
I normally use document height.
Height of Image: Check this thread out.
Incase the link breaks:
var img = document.getElementById('imageid');
//or however you get a handle to the IMG
var width = img.clientWidth;
var height = img.clientHeight;