This thread mentions a plugin that you might find useful. Perhaps it could be adapted to what you need:
http://groups.google.com/group/jquery-en/browse_thread/thread/c16b9095538c3344 On Aug 28, 12: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