Skip to main content
Code Review

Return to Revisions

2 of 3
fixed code

Can't say if this is much faster, but it's more concise

jQuery(document).ready(function($) {
 "use strict";
 var firstItems = $('.item.first');
 firstItems.each(function() {
 var $first, row, headings, heights, maxHeight;
 
 $first = $(this);
 
 // Get collection of "columns"
 row = $first.add($first.nextUntil(firstItems));
 
 // Find each column's heading
 headings = row.find("h2"); 
 // Get the heights of the headings
 heights = headings.map(function () {
 return $(this).outerHeight();
 }).toArray();
 
 // Get the maximum
 maxHeight = Math.max.apply(null, heights);
 
 // Set the heading heights to the maximum
 headings.css("height", maxHeight);
 });
});​​​

--Edit--

In my particular instance, the above script had conflict issues with prototype, since it lives inside a Magento install. I sought help and found this improvement.

/Jezen

Flambino
  • 33.3k
  • 2
  • 46
  • 90
default

AltStyle によって変換されたページ (->オリジナル) /