Calculate Width of Inner Divs

/ Published in: jQuery
Save to your folder(s)

For overflow-x, helpful to have total width of inner divs and set the parent. This uses jQuery 1.3.2

Copy this code and paste it in your HTML
  1. //using jquery
  3. var width = 0;
  5. $('#id-of-container-element').each(function() {
  6. width += $(this).outerWidth( true );
  7. });
  9. //optionally set the width of the container element
  10. $('#id-of-container-element').css('width', width);

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.