Hi,

for the jquery cycle script I need to generate a wrap around every 4 dynamicly created div's of the same class.

for example, If the following posts are generated:

Code:
<div id="postscontainer">
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
  <div class="post"></div>
</div>
It actually needs to generate this:

Code:
<div id="postcontainer">
   <div class="4postwrap">
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
   </div>
   <div class="4postwrap">
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
   </div>
   <div class="4postwrap">
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
   </div>
   <div class="4postwrap">
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
          <div class="post"></div>
   </div>
</div>
I've already managed to get this, of which I think i'm getting close:

Code:
var $posts= $('.post')
var numPosts= $posts.length;

for ( i=0; i< numPosts; **AND THEN?**){
 
// create new div and append pairs of posts into new div- then put the new div into id="postcontainer"
    $('<div class="4postwrap"></div>').append($posts.eq(i)).append($posts.eq(i+1)).appendTo('#postcontainer');
}
Can anyone tell me what to fill in at the for loop to make it work?

Thanks.

Dan