gpt4 book ai didi

javascript - 选择所有元素的最大高度

转载 作者:行者123 更新时间:2023-11-29 18:35:09 26 4
gpt4 key购买 nike

这是我的代码。

    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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com