我正在尝试使用jQuery从div中的前3个元素中找到最高元素,然后将所有3个高度设置为相同高度,然后检查下一个3并设置它们。 。如果我的窗口宽度== X,如果窗口宽度是< X然后找到最高的2个元素,然后设置它们,然后接下来的2,然后下2等jQuery将元素的高度设置为组中最高的
这是我目前的代码适用于所有元素,我只想通过组(2和3)中的元素进行查看,并根据结果和窗口大小设置该组的高度。
// 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");
});
});
任何帮助是非常赞赏:)