cssjs-func-lib/form.js
2020-02-14 20:14:24 +01:00

12 lines
468 B
JavaScript

addAutoresize = function() {
document.querySelectorAll('[data-autoresize]').forEach(function(element) {
element.style.boxSizing = 'border-box';
var offset = element.offsetHeight - element.clientHeight;
document.addEventListener('input', function(event) {
event.target.style.height = 'auto';
event.target.style.height = event.target.scrollHeight + offset + 'px';
});
element.removeAttribute('data-autoresize');
});
}
addAutoresize();