Created
September 18, 2009 20:23
-
-
Save tsmango/189275 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!-- Automatically resize a textarea's height (like Facebook) --> | |
<textarea id="comment" rows="1" cols="50"></textarea> | |
<script type="text/javascript" charset="utf-8"> | |
function autoResize(fieldId) { | |
var length = $(fieldId).value.length; | |
if(length > 0) { | |
$(fieldId).rows = Math.floor(length / $(fieldId).cols) + 1; | |
} else { | |
$(fieldId).rows = 1 | |
} | |
} | |
$('comment').observe('keyup', function(){autoResize('comment');}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment