Skip to content

Instantly share code, notes, and snippets.

@webinmd
Created June 20, 2018 07:15
Show Gist options
  • Save webinmd/8a27f8eb4542c2b484b4f5d1ef2ad911 to your computer and use it in GitHub Desktop.
Save webinmd/8a27f8eb4542c2b484b4f5d1ef2ad911 to your computer and use it in GitHub Desktop.
// textarea auto expand
var textarea = document.querySelector('textarea');
textarea.addEventListener('keydown', autosize);
function autosize(){
var el = this;
setTimeout(function(){
el.style.cssText = '';
el.style.cssText = 'height:' + el.scrollHeight + 'px';
},0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment