I have this code for textarea autoheight
function h(el) {
$(el).height(el.scrollHeight);
}
$('textarea').each(function () {
h(this); // works
//$(this).height($(this).scrollHeight); // doesn't work
});
$('textarea').on('input', function () {
h(this); // works
//$(this).height($(this).scrollHeight); // dosen't work
});
If I replace h(this)
with commented lines - they doesn't work.
What is the reason?