It might look like this:
var overall_width = 0;
$('#container > div').each(function(index, elem) {
var $elem = $(elem);
overall_width += $elem.outerWidth() + parseInt($elem.css('margin-left'), 10) + parseInt($elem.css('margin-right'), 10);
});
$(document.body).width(overall_width);
This would add the width of the children div node
along with the field (if any) and finally set the width from document.body
.
jAndy source
share