I need to display multiple rows of products, each row containing 4 products. The code snippet below shows an example with only 1 product. To create a row with 4 products, the code for
<div class='col-xs-6 col-sm-3 col-md-3'>
needs to be repeated 3 more times within <div class="row">
:
<div class="row">
<div class='col-xs-6 col-sm-3 col-md-3'>
<div class='thumbnail'>
<div class = 'matchHeight'><a href='www.url.com'><img src='product.jpg' alt='product'></a></div>
<div class='caption' style = 'text-align: center;'>
<div style = 'height: 60px;'>Product Name<br />
£9.99</div>
<p style = 'padding-top: 10px;'><a href='www.url.com' class='btn btn-primary btn-thumbp' role='button'>View</a>
</div>
</div>
</div>
</div>
The jQuery function below calculates the height of each 'matchHeight' div, finds the tallest height, and then sets all divs to the same height:
boxes = $('.matchHeight');
maxHeight = Math.max.apply(
Math, boxes.map(function() {
return $(this).height();
}).get());
boxes.height(maxHeight);
My webpage consists of multiple <div class="row">
elements. Is there a way to make the above function run independently for each row? I want the height calculation to be specific to each row and not affect other rows on the page.