如何使用JQuery找到最短的div [英] How to find shortest div with JQuery

查看:54
本文介绍了如何使用JQuery找到最短的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div id="c1" class="features" style="height:100px;width:100px;"></div>
<div id="c2" class="features" style="height:120px;width:100px;"></div>
<div id="c3" class="features" style="height:90px;width:100px;"></div>
<div...> 

如何使用JQuery查找最短的 div

How do I use JQuery to find the shortest div?

例如,上面的结果会导致div id =c3,因为它的高度为90px。

For example, the above would result in div id="c3" because its height is 90px.

推荐答案

var shortest = [].reduce.call($(".features"), function(sml, cur) {
    return $(sml).height() < $(cur).height() ? sml : cur;
});

这篇关于如何使用JQuery找到最短的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆