jquery - Adjust TD height depending on textarea rows -
i have textarea rows="1" inside <td>, takes little space possible when empty.
now wondering, how best "expand" textarea when user presses enter key?
i have put simple jsfiddle test idea. unfortunately not jsfiddle, did not know how (or if) possible use .on() or other event listeners, have put one-time update runs when jsfiddle ran.
so far works, wondering if there's better/more efficient way it.
ps call function thinking use keypress , code found here on so
var code = (e.keycode ? e.keycode : e.which); if(code == 13) { //enter keycode //expand() }
try this:
$('.expand').on('keypress', function (e) { var code = (e.keycode ? e.keycode : e.which); if (code == 13) { // enter pressed... here... var rows = $(this).attr('rows'); var rowsnew = parseint(rows) + 1; $(this).attr('rows', rowsnew); } });
Comments
Post a Comment