下面这个函数,对于需要进行动态排版的开发人员非常有用。
var getmaxheight = function ($elms) { var maxheight = 0; $elms.each(function () { // in some cases you may want to use outerheight() instead var height = $(this).height(); if (height > maxheight) { maxheight = height; } }); return maxheight; };
使用方法:
$(elements).height( getmaxheight($(elements)) );
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
判断日期是否有效的javascript代码段
node.js的event loop详解
javascript的定时器详解
以上就是 获取一组元素的最大宽度或高度javascript代码的详细内容。
