JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<div id="myNote">
Finally, designing the last sentence in this way has the added benefit of seamlessly moving the reader to the first paragraph of the body of the paper. In this way we can see that the basic introduction does not need to be much more than three or four sentences in length. If yours is much longer you might want to consider editing it down a bit!
Here, by way of example, is an introductory paragraph to an essay in response to the following question:
</div>
<button id="insert">insert</button>
CSS
#myNote {
width: 300px;
line-height: 1;
height:auto;
text-align:justify;
}
JavaScript
$("#insert").click(function() {
insertTextAtLine($("#myNote"),4," INSERT TEXT ") ;
});
function insertTextAtLine(target,lineNumber,textInsert){
var words = target.text().split(' ');
var text = '';
$.each(words, function(i, w){
if($.trim(w)) text = text + '<span>' + w + '</span> '; }
);
target.html(text);
var line = 0;
var prevTop = - parseFloat($("#myNote").css("line-height"));
$('span', target).each(function(){
var word = $(this);
var top = word.offset().top;
if(top != prevTop){
prevTop = top;
line++;
}
word.attr('class', 'line' + line);
});
var insert=$('<span />').text(textInsert);
var index=target.find('.line'+lineNumber).first().prepend(insert)
};