JSFiddle - React, Tailwind, and code Playground

HTML

<div>&nbsp;</div>
<textarea rows='10' cols='50'></textarea>

JavaScript

$('textarea').keyup(function() {
    if ($(this).val().lastIndexOf('\n')!=-1)
        x = $(this).val().split('\n');
    $('div').text(x.length); // This will be the line number
});