@Danny, that's absolutely brilliant! I am very impressed with that elegant solution. You've done me a kindness, and I appreciate that very much.
**--** Steve On Aug 28, 11:02 pm, Danny <[EMAIL PROTECTED]> wrote: > A quick plugin that I think will work for you: > $.fn.orphans = function(){ > var ret = []; > this.each(function(){$.each(this.childNodes, function() {if > (this.nodeType == 3) ret.push(this)})}); > return $(ret); > } > > You may want to test for empty text nodes though; change the if clause > to (this.nodeType == 3 && $.trim(this.nodeValue)) > > Danny > > On Aug 28, 2:30 pm, Steven Black <[EMAIL PROTECTED]> wrote: > > > I develop and host wikis where users enter free-form text, and my > > server-side parsers create WISIWYG HTML from this. > > > Of course, users can, and do, submit almost anything, and on the > > server-side I do a pretty good job of marking it up properly. But > > addressing edge-cases makes the server-side parsing increasingly > > heavy. > > > One such edge case is islands of text that are not in any tag other > > than the global containing DIV. Like this: > > > <div class="container"> > > <h3>I am text within a tag</h3> > > I am a text island child of the "container" div wrapper. <--- My > > edge case > > <p>I am also text within a tag</p> > > </div> > > > QUESTION: Using jQuery, how would you select orphan text inside a DIV > > in order to $.wrap() it, say, in a "<p>" tag? > > > I'm thinking I could ask the client browsers to address some of these > > edge-cases for me. > > > Ideas? Something like $ > > (".container").textFragmentsNotInsideAnyOtherTag() > > > **--** Steve