You have already selected an answer, but for anyone else looking for a solution to the same problem, I suggest you try this :
You can see this code working here : http://jsfiddle.net/akmozo/n29pprf6/
JS code: ( comments inside the code )
<script>
function set_ellipses_by_word(txt_element, max_width){
// if max_width is undefined, we take current text element width
max_width = typeof max_width == 'undefined' ? $(txt_element).width() : max_width;
// get the text element type
var elm_type = $(txt_element)[0].nodeName;
// init vars
var txt = $(txt_element).text(),
// convert our text to an array
arr = txt.split(' '),
str = '', current_width = 0,
// you can adjust this value according to your font and font-size ...
max_margin = 4;
// create a temporary element for the test, it should have the same font properties of the original element
$('body').append('<'+elm_type+' class="txt_temp" style="display:block;float:left;"></'+elm_type+'>');
for(var i=0; i<arr.length; i++){
// we use str to add words everytime
// i = 0 : str = "Lorem"
// i = 1 : str = "Lorem ipsum"
// i = 3 : str = "Lorem ipsum dolor sit"
// ...
str += (str != '' ? ' ' : '' ) + arr[i];
// set our temporary text element text
$('.txt_temp').text(str + '...');
// compare our temporary text element width and our max width, It should lower than our max width
if($('.txt_temp').width() < max_width){
current_width = $('.txt_temp').width();
}
}
// remove temporary text element
$('.txt_temp').remove();
if(current_width > 0){
// set ou text element width
$(txt_element).css('width', current_width + max_margin + 'px');
}
}
// original text is :
// Lorem ipsum dolor sit amet ipsum dolor sit amet
// text visible with initial css params with 180px width gives :
// on chrome 38 : Lorem ipsum dolor sit a...
// on firefox 33 : Lorem ipsum dolor sit ame...
// on internet explorer 10 : Lorem ipsum dolor sit a...
// using set_ellipses_by_word gives :
// on chrome 38 : Lorem ipsum dolor sit...
// on firefox 33 : Lorem ipsum dolor sit amet...
// on internet explorer 10 : Lorem ipsum dolor sit...
set_ellipses_by_word($('.comment'));
</script>
Original text is :
Lorem ipsum dolor sit amet ipsum dolor sit amet
Initial css params with 180px width give :
on chrome 38 : Lorem ipsum dolor sit a...
on firefox 33 : Lorem ipsum dolor sit ame...
on internet explorer 10 : Lorem ipsum dolor sit a...
Using set_ellipses_by_word
gives :
on chrome 38 : Lorem ipsum dolor sit...
on firefox 33 : Lorem ipsum dolor sit amet...
on internet explorer 10 : Lorem ipsum dolor sit...