Skip to content

Instantly share code, notes, and snippets.

@yagopv
Created September 3, 2013 14:54
Show Gist options
  • Save yagopv/6424994 to your computer and use it in GitHub Desktop.
Save yagopv/6424994 to your computer and use it in GitHub Desktop.
Automatic textarea resizing
textarea {
resize: vertical;
overflow-y: hidden; /* prevents scroll bar flash */
padding-top: 1.1em; /* prevents text jump on Enter keypress */
}
// Automatic resizing for textareas
// auto adjust the height of
$(document).on('keyup', 'textarea', function (e) {
$(this).css('height', 'auto');
$(this).height(this.scrollHeight);
});
$("textarea").keyup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment