I have following script:
var height = 0;
$('.scroller').each(function() {
$(this).children('div').each(function() {
if (height < $(this).height()) {
height = $(this).height();
}
});
$(this).css("height", height + "px");
});
What it does:
- loop through each
children divinside each.scrollerdiv height < $(this).height()= if height of the currently loopeddivis bigger than0it is setting the height of this div asnew value of the height variable- this way is finding the highest div element in each
.scrollerdiv - than, the height (height of the highest element ) is set to
.scrollerdiv
The issue:
- if any element inside first '.scroller' is higher than ANY element in the second
.scrollerit is setting the height (highest element in first.scroller) also to secondscroller- example: http://jsfiddle.net/MrTest/7jAAG/20/
Is element in the first .scroller are not higher than elements in second .scroller everything works fine - example: http://jsfiddle.net/MrTest/7jAAG/16/
I think the problem is setting the height var - how can I reset this value to 0 BEFORE going to loop though second .scroller ?