我使用这个脚本来平衡元素的高度:查找最长的元素(jQuery的)
(function ($) {
$.fn.autoheight = function() {
var height = 0,
reset = $.browser.msie ? "1%" : "auto";
return this.css("height", reset).each(function() {
height = Math.max(height, this.offsetHeight);
}).css("height", height).each(function() {
var h = this.offsetHeight;
if (h > height) {
$(this).css("height", height - (h - height));
};
});
};
})(jQuery);
我想只是一个额外的功能添加到它 - addclass“最长的”以时发现最长的元素均衡高度,我在上面的脚本中改变了什么?
非常感谢。
你的意思是最宽吗? – 2010-03-03 12:06:12
它关于平衡高度,所以'最长'更合适? – 3zzy 2010-03-03 12:11:00
“最高”或“最高”或可能“最大”更合适。宽度 - >最宽,高度 - >最高/最高,长度 - >最长。 – cletus 2010-03-03 12:13:42