TextArea with css resize

does not work.

by jank0003

HTML

<table>
    <tr>
        <th>FirstCol</th>
        <th>SecondCol</th>
    </tr>
    <tr>
        <td><textarea>Write something here</textarea></td>
        <td><textarea>Write something here</textarea></td>
    </tr>
     <tr>
        <td><textarea>Write something here</textarea></td>
        <td><textarea>Write something here</textarea></td>
    </tr>
    
</table>

CSS

table, td, th {
    border: 1px solid green;
}

th {
    background-color: green;
    color: white;
}

JavaScript

function h(e) {
    $(e).css({'height':'auto','overflow-y':'hidden'}).height(e.scrollHeight);
}
$('textarea').each(function () {
  h(this);
}).on('input', function () {
  h(this);
});