Ok, I think I worked out my own solution.  If anyone sees and problems
with this working when adding more items to the list please let me
know.  So far it is working great!

        var total_artists = $('#artistsColumns p').length;
        var total_artists_mod = total_artists % 3;
        var total_artists_col = total_artists / 3;
        $('#artistsColumns p').slice(0 , total_artists_col).addClass
('first');
        $('#artistsColumns p').slice(total_artists_col , total_artists_col *
2).addClass('second');
        $('#artistsColumns p').slice(total_artists_col * 2 ,
(total_artists_col * 3) + total_artists_mod).addClass('third');

        // Now lets wrap those in some divs
        $('p.first').wrapAll('<div class="colFirst"></div>');
        $('p.second').wrapAll('<div class="colSecond"></div>');
        $('p.third').wrapAll('<div class="colThird"></div>');

On Mar 3, 11:02 am, brian <bally.z...@gmail.com> wrote:
> On Tue, Mar 3, 2009 at 1:48 PM, Nic Hubbard <nnhubb...@gmail.com> wrote:
>
> > Should I keep the division by 10 on the Math function?
>
> No, as i said, that's the problem. There's not only no need for it,
> but it's giving you results you don't want. Quick: what's zero divided
> by ten? And what's the remainder of that result divided by 3?
>
> This should help to illustrate what's going on:
>
> $('#artistsColumns p').each(function(i){
>         var d = Math.floor(i/10);
>         var n = d % 3;
>         $(this).html('<strong>d:' + d + ' n:' + n + '</strong><br />' +
> $(this).html());
>         $(this).addClass(classNames[n]);
>
> });

Reply via email to