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
  2.  
  3. var width = 0;
  4.  
  5. $('#id-of-container-element').each(function() {
  6. width += $(this).outerWidth( true );
  7. });
  8.  
  9. //optionally set the width of the container element
  10. $('#id-of-container-element').css('width', width);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.