Last active
March 2, 2016 14:56
-
-
Save superhero/1be4fd89bd7e0b4552ce to your computer and use it in GitHub Desktop.
Expands the textarea depending on content
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
(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