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

前端 未结 9 1459
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条回答
  •  离开以前
    2021-01-04 00:09

    More modern option:

    let height = 0
    $('.profile').each((i, el) => height += $(el).outerHeight())
    

提交回复
热议问题