Truncate text/string using jQuery

Yesterday I need to truncate string and I was asking myself "How Can I Truncate A String In jQuery?". There are already many jQuery plugins available to truncate the text/string but there is an issue with these plugin. They actually limits the character length of the text, instead of fitting the text with respect to width of container.

But now, there is a jQuery plugin called "trunk8" which works intelligently and fits the text as per the width of container.

trunk8 is an intelligent text truncation plugin to jQuery. When applied to a large block of text, trunk8 will cut off just enough text to prevent it from spilling over. This plugin measures the content area for spill-over and intelligently chooses the text that best fits in the given space.

To use this plugin, all you need to do is to call "trunk8()" method on the selector.
$(document).ready(function() {
You can also define the number of lines of text-wrap to tolerate before truncating.
$(document).ready(function() {
    lines: 2
Visit official website for all the options to customize this plugin.

Feel free to contact me for any help related to jQuery, I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..