I'm a little confused; you've said ".filter() doesn't work against text nodes (they're immediately removed)" but then you suggest accessing text nodes by using .filter?
On Feb 20, 11:39 am, John Resig <jere...@gmail.com> wrote: > .not() and .filter() don't work against text nodes (they're > immediately removed). If you wish to just get the text nodes you can > do: > > $("p").contents().filter(function(){ return this.nodeType !== 1; }) > > Although, it sounds like you're trying to do this instead: > > $("p").wrapInner("<b></b>"); > > --John > > On Fri, Feb 20, 2009 at 9:11 AM, David <david.kar...@gmail.com> wrote: > > > According to the documentation, .contents() should "Find all the child > > nodes inside the matched elements (including text nodes)". However, > > in the example given there, when the jquery > > $("p").contents().not("[nodeType=1]").wrap("<b/>") > > is applied to the content > > <p>Hello <a href="http://ejohn.org/">John</a>, how are you doing?</ > > p> > > only the text "John" is made bold---in other words, jquery is failing > > to select the text nodes containing "Hello" and ", how are you doing" > > > Since I would very much like to be able to select the text nodes, can > > someone explain what is going on here? > > > Thanks > > David