L'alternativa JavaScript al metodo .outerHeight() con margini di jQuery

JavaScript offre un semplice modo per ottenere l'altezza esterna del box contenitore di un elemento compresi i margini.

La soluzione รจ la seguente:


function outerHeight(el) {
  var height = el.offsetHeight;
  var style = getComputedStyle(el);

  height += parseInt(style.marginTop,10) + parseInt(style.marginBottom,10);
  return height;
}

Torna su