I am currently getting the size of some images in an each()
statement.
I am binding a function to it's load event. Although, I need it to obtain the images height before continuing code execution.
$(window).load(function () {
$("element").each( function() {
/*
.
.
.
.
*/
var containerHeight = $(this).height();
var imgHeight = 0;
//get the size of the full image.
var imgLoad = $("<img />");
imgLoad.attr("src", imgSrc);
imgLoad.bind("load", function () { imgHeight = this.height; });
heightDiff = (imgHeight - containerHeight);
//some methods are called...
//imgHeight is still set to 0
});
});
I considered using .trigger("custom-event")
and then checking if it was called with Jquerys .when()
method
But is there a easier (if not better) way in doing this?
Regards,