Prasad
Prasad

Reputation: 1812

How to get image height from dom tree using jQuery when height attribute is not set

I want to get image height and width when it is not set from height attribute and not also set in css. Real height and width of image which we get in dom tree or when browser render image with image's original height and width. I tried following but didn't worked,

$("#idname img").attr('height');

but this need height attribute to set in image<>

Upvotes: 0

Views: 129

Answers (2)

flec
flec

Reputation: 3019

You can use the height method

$("#idname img").height()

but you have to call it in the window-load event (instead of the dom-ready) because images are not loaded in the dom.

$(window).load(function ()

Upvotes: 3

ButterDog
ButterDog

Reputation: 5225

Use this:

$("#idname img").height()

Upvotes: 1

Related Questions