Skip to content

Instantly share code, notes, and snippets.

@superhero
Last active March 2, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superhero/1be4fd89bd7e0b4552ce to your computer and use it in GitHub Desktop.
Save superhero/1be4fd89bd7e0b4552ce to your computer and use it in GitHub Desktop.
Expands the textarea depending on content
(function($)
{
$(document).on('input', 'textarea', function()
{
var $this = $(this);
var padTop = parseInt($this.css('padding-top'), 10);
var padBot = parseInt($this.css('padding-bottom'), 10);
$this.height(0);
var scroll = $this.prop('scrollHeight');
$this.height(scroll - padTop - padBot);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment