JSFiddle - React, Tailwind, and code Playground

HTML

<div id=output class=vslide_text>The .wrapInner() function can take any string or object that could be passed to the $() factory function to specify a DOM structure. This structure may be nested several levels deep, but should contain only one inmost element. The structure will be wrapped around the content of each of the elements in the set of matched elements.</div>

CSS

.vslide_text {
  line-height: 1.2em;
  height: 3.6em;
  overflow: hidden;
  width: 200px;
  //border:1px dotted gray;
  //padding:0.5em;
}

JavaScript

$('#output').wrapInner('<div/>');
var originaltext = $('#output div').text();

var t = originaltext;

while (true) {
  if ($('#output div').height() <= $('#output').height()) {
    break;
  }

  $('#output div').text(t.substring(0, t.lastIndexOf(" "))+"...");
  t = $('#output div').text();
}

//$('#output div').text(originaltext);

alert('Visible text : "' + originaltext.substring(0, t.length) + '"');
alert('Hidden text : "' + originaltext.substring(t.length) + '"');