Skip to content

Instantly share code, notes, and snippets.

View adrienchretien's full-sized avatar

Adrien CHRETIEN adrienchretien

View GitHub Profile
@adrienchretien
adrienchretien / AutoSize.js
Created December 8, 2013 09:36
Resize an element when the visitor create(or remove) a new line on a text field (like a textarea)
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);