Very interesting requirement. Let assume each lines are being separated by newline '\n', on textarea click, you can write something like below
1. Get the value in the textarea
2. Get the row number where the cursor landed on
3. Get the text from the selected row (t.value.split("\n")[rowNumber-1])
function getline()
{
var t = $("#t")[0];
let rowNumber = t.value.substr(0, t.selectionStart).split("\n").length;
console.log(t.value.split("\n")[rowNumber-1]);
alert(t.value.split("\n")[rowNumber-1]);
}
Here is an example:
CP_textarea - JSFiddle[
^]
Tested on: Firefox
Reference:
javascript - Getting Line Number In Text Area - Stack Overflow[
^]