Looping through children elements using each.
var divHeights = [];
$('#parent').children('div').each(function () {
divHeights.push(this.clientHeight);
});
alert(divHeights); // fails
How can I return the divHeights variable?
I've tried
var hts = ('#parent').children('div').each(function () { ...
but obviously that won't work.
divHeightsshould contain them after the.eachstatement. So just use it afterwards.return divHeights;after the loop. What's not working about that?divHeights? When I run it,divHeightsgets filled in as expected