Your initial code  block:

$('.wordbreakfield').each(function(){
  $(this).text();
});

...doesn't do anything with the text(). You retrieve it but it's not used.


On 4/6/07, Yansky <[EMAIL PROTECTED]> wrote:


Hi, thanks for the reply. I'm still a bit confused though. :)

If "$('.wordbreakfield')" returns an array of jquery objects, then
".each(function(){" applies a function to the raw DOM of each element,
& using "$(this)" accesses the jquery object rather than the raw DOM
so we can use the "text()" function.

So why doesn't that translate to "get the text for each jquery object
in the array"?

On Apr 6, 6:39 pm, [EMAIL PROTECTED] wrote:
> Because:
>
> On Apr 6, 7:58 am, "Yansky" <[EMAIL PROTECTED]> wrote:
>
> > $.map(theData, function(i){
> >   return i.childNodes[0].nodeValue;
>
> > });
>
> The .map function is returning an array of the result of each function
> call - in your case:
>
> >   return i.childNodes[0].nodeValue;
>
> You second block doesn't work because ...
>
> >  $(this).text();
>
> ...isn't actually returning anything.
>
> Try this:
>
> var myData = [];
> $('.wordbreakfield').each(function() {
>   myData.push($(this).text());
>
> });
>
> That said, you've almost got what you need with the map function
>
> var myData = $.map($('.wordbreakfield'), function() {
>   return $(this).text();
>
> });
>
> Hope that helps.


Reply via email to