jQuery:同一class下,如何获取多个div的中的最大高度值

第一:要理解Jq中的获取高度的三个方法height()、 innerHeight()、outerHeight()

height():height

innerHeight():height+padding

outerHeight():height+padding+border   ;outerHeight(true) :height+padding+border+margin。

第二:一般用innerHeight()方法就可以了

$(function() {

var h_max = 0;

$(".className").each(function(){

    var  h = $(this).innerHeight();

    h_max = h_max < h ? h : h_max;

})

$(".className").css('height',h_max);

})

猜你喜欢

转载自blog.csdn.net/weixin_42957379/article/details/83748511
今日推荐