Thanks again, John.

I'm pretty sure that this would wrap _all_ of the child nodes, and not
just the text nodes, correct? Also, in the jQuery philosophy of "get
things, do stuff", I'm trying to separate the getting from the doing,
using a custom function to "fake" a selector, and then another
function to operate on the matching nodes.

jQuery currently ignores all text nodes during selection, so a custom
selector is out of the question now, but do you think it'd be possible
to add support for a text node selector such as ":text" at some point
in the future?

Jed Schmidt

On Aug 12, 10:03 pm, "John Resig" <[EMAIL PROTECTED]> wrote:
> If that's what you're after, give this a try:
>
> $("div").each(function(){
>   $(this.childNodes).wrap("<span></span>");
>
> });
>
> --John
>
> On 8/11/07, Jed Schmidt <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks for the tip, John.
>
> > Maybe I don't quite grok it, but could it handle cases like this?
>
> > <div>This is <b>bold</b>.</div>
>
> > It seems to me that innerWrap could give me this:
>
> > <div><span>This is <b><span>bold</span></b>.</span></div>
>
> > but what I'm really after is this:
>
> > <div><span>This is </span><b><span>bold</span></b><span>.</span></div>
>
> > In other words, I'm looking for a way to manipulate all text nodes
> > themselves, regardless of whether they are the sole children of their
> > parent node. Since jQuery ignores text nodes, I think I would have to
> > use a custom traverse function instead. Does this make sense?
>
> > Jed Schmidt
>
> > On Aug 12, 12:50 am, "John Resig" <[EMAIL PROTECTED]> wrote:
> > > How about using 
> > > innerWrap?http://blog.brandonaaron.net/2007/06/04/jquery-snippets-innerwrap/
>
> > > --John
>
> > > On 8/11/07, Jed Schmidt <[EMAIL PROTECTED]> wrote:
>
> > > > Looking into the jQuery source, it seems like this would be pretty
> > > > daunting ("nodeType == 1" is checked in 5 different places, making it
> > > > seem like a non-trivial fix).
>
> > > > Perhaps the next best bet after a proper selector would be a function
> > > > that, for each matched element, adds the jQuery objects for itstext> 
> > > > nodechildren, and then removes the original element. Can something
> > > > like this be done in jQuery?
>
> > > > Thanks again for any advice,
>
> > > > Jed Schmidt

Reply via email to