Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically resize input

Tags:

jquery

input

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

like image 666
Matt Avatar asked Mar 26 '26 02:03

Matt


1 Answers

Here's a quick (untested) solution

$('input[type="text"]').keyup(function(){
  $(this).attr({width: 'auto', size: $(this).val().length});
});
like image 105
czarchaic Avatar answered Mar 28 '26 15:03

czarchaic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!