tags:

views:

95

answers:

2

Hey all,

I was just wondering how do you dynamically resize an input as you type in it??

I'd like to use jQuery if possible & I would rather it be a small script than a bulky plugin.

Please let me know, Matt Mueller

A: 

I found this lightweight one. This is for textareas

jQuery plugin: ‘autoResize’

Full version : ~4k

Minified : ~1k

rahul
I need it for inputs not for textareas. I checked that one out also. It looks like it bases its resize off of how many times you hit return.. that won't work. I want it to resize right when it reaches the end of the input box.
Matt
+1  A: 

Here's a quick (untested) solution

$('input[type="text"]').keyup(function(){
  $(this).attr({width: 'auto', size: $(this).val().length});
});
czarchaic
I'll give this a go and let you know. Thanks!
Matt