Get the sum of the outerHeight of all elements of the same class

前端 未结 9 1583
Happy的楠姐
Happy的楠姐 2021-01-03 23:46

I think this is a pretty straightforward problem but...

var outerHeight = $(\'.profile\').outerHeight();
$(\"#total-height\").text(outerHeight + \'px\');
         


        
9条回答
  •  旧时难觅i
    2021-01-04 00:06

    Try this:

    var outerHeightTotal = 0;
    $('.profile').each(function(){
      outerHeightTotal += $(this).outerHeight();
    });
    

提交回复
热议问题