.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
>

Reply via email to