JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="mytextarea">this is test1
and this is test2
plus it is test3</textarea>
<button onclick="alert(testpos(prompt('Which position to test?')))">Test Position</button>
<script>
function testpos(pos) {
var text = document.getElementById("mytextarea").value.split("\n");
var lines = [0];
for (i=1;i<text.length;i++) {
lines.push(lines[i-1]+text[i-1].length+1)
}
return lines.indexOf(parseInt(pos))!=-1
}
</script>