[jQuery] Re: copy values to an array

2008-02-05 Thread paulj
Jonathan and Karl : thanks for your replies. Jonathan : I probably gave the impression that I wanted each 3rd value copied to each array element. Your code worked brilliantly for that and I've stored it away for another day. Karl: that's exactly what I wanted. Problem solved. (BTW I use your 'R

[jQuery] Re: copy values to an array

2008-02-04 Thread Karl Swedberg
Oops. I forgot to take out the "ul:first " part of the selector. I had put that in there when I was testing on a random page in Firebug, so you can safely take it out. Also, if your LIs just have text in them, you can use $(this).text() instead of $(this).html() --Karl On Feb 4, 2008, a

[jQuery] Re: copy values to an array

2008-02-04 Thread Karl Swedberg
Hi Paul, I may have misunderstood what you were going for, but here is a different approach, just in case you were looking for an array like ['abc', 'def', 'ghi']: var txt = '', array1 = []; $('ul:first li').each(function(i){ txt = txt + $(this).html(); if (i % 3 == 2) { ar

[jQuery] Re: copy values to an array

2008-02-04 Thread Jonathan Sharp
Hi Paul, This should do the trick: $('li').each(function(i){ array1[ Math.floor( i / 3 ) ] = $(this).html(); }); Cheers, -Jonathan On 2/4/08, Paul Jones <[EMAIL PROTECTED]> wrote: > > > I know the following would work if I wanted to copy the values of *each* > > to a separate array elemen