Created
September 3, 2013 14:54
-
-
Save yagopv/6424994 to your computer and use it in GitHub Desktop.
Automatic textarea resizing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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