这是我的代码。
v=dom.find("ul:first").outerHeight(); // the height of the first li element
// instead of taking the height of the first li element, it should loop through all
// li elements and set v to the element with the biggest height
代码中间的注释几乎解释了一切。我需要循环遍历所有 li 元素并取最大的高度,而不是取第一个元素的高度。
最佳答案
var v = 0;
// ...
dom.find('ul:first').children('li').each(function() {
var height = $(this).outerHeight();
v = height > v ? height : v;
});
关于javascript - 选择所有元素中最大的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4008851/