Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrien CHRETIEN adrienchretien

View GitHub Profile
@adrienchretien
adrienchretien / AutoSize.js
Created Dec 8, 2013
Resize an element when the visitor create(or remove) a new line on a text field (like a textarea)
View AutoSize.js
function AutoSize(textarea) {
textarea.className += ' js-autosize';
function resize() {
textarea.style.height = 'auto';
var height = textarea.scrollHeight;
if (window.getComputedStyle) {
var styles = window.getComputedStyle(textarea);