Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get image height after image has loaded

Tags:

jquery

I am trying to get image height after image has loaded. The reason for that is chrome gets false height values because it gets height before image has loaded.

var imgHeight = $("#pic25").height();

Note: I shouldn't use $(window).load(function(){ on this one.

How can I do that ?

like image 917
user198989 Avatar asked Jan 03 '13 06:01

user198989


People also ask

How can get image width and height in jquery?

var imageWidth = $(Imgsize). width(); alert(imageWidth);

What is image height?

Description. The Image Height is one part of the information that determines a picture's, photo's or other image's dimension. Together with the image width, this value determines the size of an image itself, not the file size. Often, Image Height is given in pixels, e.g. 682 px.


1 Answers

you need to use onload(.load()) event since load event will be called only after the DOM and associated resources like images got loaded, so it work properly

$(body).load(function(){
  var height = $("#pic25").height();
});

this would work

to check particular image to be load you can do this like @arvind answers code

like image 113
NullPoiиteя Avatar answered Sep 28 '22 10:09

NullPoiиteя