Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created March 29, 2012 22:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/2244501 to your computer and use it in GitHub Desktop.
Save ziadoz/2244501 to your computer and use it in GitHub Desktop.
jQuery TextArea Auto Height
$('textarea.notes').on('focus blur keyup', function() {
var paddingTop = $(this).css('padding-top').replace('px', ''),
paddingBottom = $(this).css('padding-bottom').replace('px', '');
$(this).css('height', '1px');
$(this).css('height', (this.scrollHeight - paddingTop - paddingBottom) + 'px');
}).blur();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment