JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td style="border:1px solid red">
<textarea class="expand" rows="1" cols="20">test</textarea>
</td>
</tr>
</table>
JavaScript
$('.expand').on('keypress', function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 13) {
// Enter pressed... do anything here...
var rows = $('.expand').attr('rows');
var rowsNew = parseInt(rows) + 1;
$('.expand').attr('rows', rowsNew);
}
});