I've created a function that loops through a set of products, and sets the height of their copy area to the height of the tallest copy area in that set.
Here's my code:
function productCopyHeight(){
//make sub range product text sections the same height
if($('.sub-range').length){
$('.sub-range').each(function(){
var itemHeight = 0;
$(this).children('.product-item').children('.copy').each(function(i){
var thisItemHeight = $(this).height();
console.log(thisItemHeight + ' > ' + itemHeight)
if(thisItemHeight > itemHeight){
var itemHeight = thisItemHeight;
}
});
$(this).children('.product-item').children('.copy').css('height', itemHeight);
})
}
}
When I log it it shows the itemHeight variable as undefined when it is defined before the each loop.
itemHeightis undefined?console.log?