Return to Snippet

Revision: 14941
at June 17, 2009 19:24 by segdeha


Updated Code
<!DOCTYPE HTML>
<html>
	<body>
		<textarea id="txtarea" style="width: 100px;,font-size: 16px;line-height: 1; height: 16px;"></textarea>
		<script type="text/javascript">
		
		document.getElementById('txtarea').addEventListener('keyup', function () {
			this.style.height = 0; // this is necessary to make it shrink when deleting
			this.style.height = this.scrollHeight + 'px';
		}, false);
		
		</script>
	</body>
</html>

Revision: 14940
at June 17, 2009 19:14 by segdeha


Initial Code
<!DOCTYPE HTML>
<html>
	<body>
		<textarea id="txtarea" style="width: 100px;,font-size: 16px;line-height: 1; height: 16px;"></textarea>
		<script type="text/javascript">
		
		document.getElementById('txtarea').addEventListener('keyup', function () {
			this.style.height = 0;
			this.style.height = this.scrollHeight + 'px';
		}, false);
		
		</script>
	</body>
</html>

Initial URL

                                

Initial Description

                                

Initial Title
Dynamically expand a textarea based on the amount of text

Initial Tags
javascript

Initial Language
JavaScript