Incremento righe textarea

Incremento righe textarea su pressione del tasto enter

by Salvatore Rotondo

HTML

<textarea id="dynamicRows" rows="5"></textarea>

CSS

textarea{background-color:#f1f1f1; border:solid 1px #f00;}

JavaScript

window.onload = function(){
    document.getElementById("dynamicRows").onkeydown = function(e){
        if ((e.keyCode && e.keyCode == 13) || (e.which && e.which == 13))
        {
            this.rows = parseInt(this.rows)+1;
        }
    };
};