Well, I suppose you could search for LAST child tag (of any type) of the selected tag, then truncate the text inside that to make sure you still keep your formatting. So given your example: <p><b>This is my string to truncate.</b></p>
You might end up with this: <p><b>This is my string to tr...</b></p> ---------- Starting with this: <div>jquery is the <i>BOMB</i> yo. It makes <a href="somelink.html">short work of coding</a></div> You'd end up with this: <div>jquery is the <i>BOMB</i> yo. It makes <a href="somelink.html">short w...</a></div> ---------- And finally, if there were no child tags: <p>I'm plain vanilla HTML and I'll die alone because I have no children</p> You'd get this: <p>I'm plain vanilla HTML and I'll die alone...</p> Your thoughts? andy -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Giant Jam Sandwich Sent: Thursday, April 05, 2007 8:25 AM To: jQuery (English) Subject: [jQuery] Re: Truncate Plugin v.2.0 Hey Andy, Sorry about that. This was an updated release of an older version (which had the description of what the plugin did). If you view the source, you can see instructions on how to use the plugin. It is not a newsreader - it is for string manipulation. I will probably update the demo to better explain that. As an aside, this will need a 2.1 update soon enough. Currently, if you were to select a parent element, and the string within that element you wanted to truncate had HTML (child elements), you would loose that formatting. For instance: <p> <b>This is my string to truncate.</b> </p> If you choose the paragraph tag as the element to parse the text, it will grab that (sans bold tag), and then append it back to the paragraph tag without the bold. I need to rethink how to handle this scenario. Any suggestions? Brian On Apr 5, 9:11 am, "Andy Matthews" <[EMAIL PROTECTED]> wrote: > What's it do? You have an example without explaining it's usage or > what exactly it does. You have news headlines on your example page, so > is it a newsreader? Your headlines are cut off so does it trim down a > string of text to a specified length? > > andy > > -----Original Message----- > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] > On > > Behalf Of Giant Jam Sandwich > Sent: Wednesday, April 04, 2007 6:35 PM > To: jQuery (English) > Subject: [jQuery] Truncate Plugin v.2.0 > > Well, I have vastly improved this script. It was my first plugin for > jQuery, and after creating a few others, I decided to go back and make > some edits on this one. You can find the demo here: > > http://reindel.com/blog/src/jquery_truncate/ > > Feedback is always welcome. > > Brian