Sorry, maybe my response was somewhat confusing, but I don't believe you'll get a concatenated string (as the OP's followup indicates).
After using .filter(), you'll get an array-like object (it's still the jQuery object) which contains the text nodes. Calling .text() on those won't actually concatenate them though, as they're text nodes. Likewise, if you do $('div').contents().text() you'll only get the text of the UL element, rather than a concatenation of that with the previous text node. @nick, you can get the text from the object with text[0].nodeValue. HTH :) On May 3, 4:08 pm, Karl Swedberg <k...@englishrules.com> wrote: > On May 2, 2009, at 9:28 PM, mkmanning wrote: > > > Don't use .text(), you'll get an array-like object of text nodes. > > Tiny clarification: you'll get a concatenated string of text nodes. > > --Karl > > ____________ > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > On May 2, 2009, at 9:28 PM, mkmanning wrote: > > > > > Don't use .text(), you'll get an array-like object of text nodes. Try > > > var text = $('div').contents().filter(function(){return > > this.nodeType==3;}); > > console.log(text) > > > On May 2, 6:06 pm, nick <nboutel...@gmail.com> wrote: > >> Thanks for the response. Are you sure thats correct though? > > >> alert($('div').contents().filter(function(){return > >> this.nodeType==3;}).text()); > > >> returns empty.