JavaScript offre un semplice modo per ottenere la larghezza esterna del box contenitore di un elemento compresi i margini.
La soluzione รจ la seguente:
function outerWidth(el) {
var width = el.offsetWidth;
var style = getComputedStyle(el);
width += parseInt(style.marginLeft,10) + parseInt(style.marginRight,10);
return width;
}