jQuery Ustaw wysokość elementu na najwyższą w grupie

Próbuję pracować z jQuery, aby znaleźć najwyższy element z pierwszych 3 elementów w div, a następnie ustawić wszystkie 3 na tej samej wysokości, a następnie sprawdzić następne 3 i ustawić je ... itd., Jeśli moja szerokość okna == X, również jeśli szerokość okna wynosi <X, znajdź 2 najwyższe elementy, a następnie ustaw je, a następnie następne 2, a następnie następne 2 itd.

To jest mój obecny kod, który działa dla wszystkich elementów, chciałbym po prostu przejść przez elementy w grupach (2 i 3) i ustawić wysokość dla tej grupy na podstawie wyniku i rozmiaru okna.

// Find highest element and set all the elements to this height.
    $(document).ready(function () {

    // Set options
    var height = 0;
    var element_search = "#cat_product_list #cat_list";
    var element_set = "#cat_product_list  #cat_list";

    // Search through the elements set and see which is the highest.
    $(element_search).each(function () {
        if (height < $(this).height()) height = $(this).height();
        //debug_(height,1);
    });

    // Set the height for the element(s if more than one).
    $(element_set).each(function () {
        $(element_set).css("height", (height+40) + "px");
    });
});

Każda pomoc jest bardzo ceniona :)

questionAnswers(3)

yourAnswerToTheQuestion