Reputation: 17
I have images, which are taken from the database. I need to get the height each of them. If I do like that:
$('.find_image_height').height();
I takes the first image height, how can I do that. (they array, of course, will help me)
Upvotes: 0
Views: 36
Reputation: 5803
function getHeights() {
var heights = [];
$(".find_image_height").each(function(){
heights.push($(this).height());
});
return heights;
}
Upvotes: 1
Reputation: 78525
You can use .map:
$(function() {
var array = $(".find_image_height").map(function() {
return $(this).height();
}).get();
});
Here is a fiddle to demonstrate.
Upvotes: 0