Text truncation is sometimes needed to display information in a cool and professional way and most of the time this is done using back-end work and not front-end. Today, I present you guys a jQuery plugin that can truncate text easily (more like a text truncation extension for jQuery actually). When applied to large blocks of texts, trunk8 (the name of the plugin) will just cut off just enough text to prevent it from overlapping the box.
So basically unlike other truncate plugins or functions, trunk8 measures the content area for “spill-over” and intelligently chooses the text that best fits in the given space. The text truncate plugin comes with some basic options by default but if needed you can set other custom options like: the string to insert in place of the omitted text (by default is “hellip;”), the number of lines of text-wrap to tolerate before truncating (default is 1), the side of the text from which to truncate (default is right), the tooltip (the title attribute of the targeted HTML element will be set to the original, untruncated string. Valid values include true and false), the width (in chars) of the desired text.
There is also an “update” option which updates the text value of the targeted HTML elements while maintaining truncation. This method can be used to recalculate the truncation after a reflow, especially after changing the text itself or its container size.