Created
June 23, 2017 09:23
-
-
Save DevShahidul/24eff7258b21fac6f5771e927e0d11aa to your computer and use it in GitHub Desktop.
This file contains 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
if($('#long-answer-box').length){ | |
var textarea = document.querySelector('textarea'); | |
textarea.addEventListener('keydown', autosize); | |
function autosize(){ | |
var el = this; | |
setTimeout(function(){ | |
el.style.cssText = 'height:auto; padding:0'; | |
// for box-sizing other than "content-box" use: | |
// el.style.cssText = '-moz-box-sizing:content-box'; | |
el.style.cssText = 'height:' + el.scrollHeight + 'px'; | |
},0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment