I'm trying to figure out how to detect line breaks (responsive) with JavaScript. I would like to remove the characters on line 3 and end line 2 with some dots like this '...'.
I know that the line-height is 20px. I know I check the amount of lines by dividing div-height / line-height. I don't know how to get the text until line 3 starts.
Tried the overflow and ellipses part from useless'MJ :
Works only on the text he gave.. not on my own text.
Update #2:
Tried the solution of Matthias, but having problems making it responsive. I've tried adding a window on resize event and an extra div with the full text.
function ellipsizeTextBox(id) {
var el = document.getElementById(id);
var fullTextEl = $(el).parent().find('.MB-Item-Description-Full').text();
var wordArray = fullTextEl.split(' ');
while(el.scrollHeight > el.offsetHeight){
wordArray.pop();
el.innerHTML = wordArray.join(' ') + '...';
}
}
window.onresize = function(event){
$( ".MB-Item-Description" ).each(function( index ) {
var id = $(this).attr('id');
ellipsizeTextBox(id);
});
}
Works great when making the browser smaller, doesn't add more words when making the browser bigger.



divmax-heightofline-heightx 2 and then addtext-overflow: ellipsisandoverflow: hidden? Sounds like a XY Problem for me.text-overflow: ellipsison multiline text