title: split html content into fixed height and width divs with jQuery
body: <p>I'm trying to split a large html page into smaller fixed height and width chunks (pages). </p>
  
  <p>Its pretty easy if I know the pages count - I can generate required number of pages first and then fill them with source content children:</p>
  
  <pre><code>children = $('#source').children();
  width = 600;
  height = 600;
  
  // already generated 'pages'
  divs = $('.page');
  $(divs).width(width);
  
  pages = divs.length;
  i = 0;
  
  for (var c = 0; c &lt; pages; ++c) {
  
      var div = $(divs).eq(c);
  
      while (i &lt; children.length &amp;&amp; div.height() &lt; height) {
          $(children[i++]).clone().appendTo(div);
      }
  
      if(div.height() &gt; height) {
          div.contents().last().remove();
          i--;
      }
  
  }
  </code></pre>
  
  <p>But how can I do the same thing if I don't know the pages count?
  How to wrap content with $('div.page') and keep adding pages until I reach the end of content?</p>
  
  <p>thanks</p>