[jQuery] Re: Get label text

2008-10-24 Thread shapper
I wrote alert(levels) to check and I get: [object Object] Does anyone knows how to get the values and join in CSV format? Thank You, Miguel On Oct 24, 1:47 am, shapper [EMAIL PROTECTED] wrote: yes, I have: var levels = []; levels = $('input:checked + label').map(function() {   return

[jQuery] Re: Get label text

2008-10-24 Thread Klaus Hartl
Ah, I forgot a little thing (documentation was a bit misleading on that). Try this: var levels = $('input:checked + label').map(function() { return $(this).text(); }).get(); For csv do: levels.join(','); And that's more or less the same as in the documentation ;-)

[jQuery] Re: Get label text

2008-10-23 Thread Klaus Hartl
You could try this (untested): var labels = $('input:checked + label').map(function() { return $(this).text(); }); That should give you an array with the label's text. --Klaus On 23 Okt., 22:47, shapper [EMAIL PROTECTED] wrote: Hello, This might be a tricky one ... I have been looking

[jQuery] Re: Get label text

2008-10-23 Thread shapper
But I can join the labels can't I? I tried: .append(levels.join(', ')) to added it to an element and I get the error in Firebug: levels.join is not a function Am I doing something wrong? Thanks, Miguel On Oct 23, 9:57 pm, Klaus Hartl [EMAIL PROTECTED] wrote: You could try this (untested):

[jQuery] Re: Get label text

2008-10-23 Thread William
Perhaps use .append(labels.join(',')) Note that the snippet from Klaus uses var *labels*, so trying to use the Array.join method of *levels* (probably undefined) will likely not work ;) On Oct 23, 2:58 pm, shapper [EMAIL PROTECTED] wrote: But I can join the labels can't I? I tried:

[jQuery] Re: Get label text

2008-10-23 Thread shapper
yes, I have: var levels = []; levels = $('input:checked + label').map(function() { return $(this).text(); }); ... .append(levels.join(',')) Still having the same error ... On Oct 24, 1:04 am, William [EMAIL PROTECTED] wrote: Perhaps use .append(labels.join(',')) Note that the snippet