Can’t seem to find out to do this in either html or JS (or maybe even jquery?).
I have a text-box that echo’s whatever is typed into it in an input box more down the page. This echo box needs to auto-fit to whatever text is inside it so that it doesn’t have this huge white space spot after the text.
Any ideas how to auto-fit a input field to text that is inserted into it?
I think you’re looking for something like this: http://jsfiddle.net/ener3/
where
#inis the id of the input, and#outis the textbox you want to autosize.You can add this to the head of the page like so:
Make sure you put the script tag after your jQuery include:
You can replace
1.8.3with the version of jQuery you want to target. I wouldn’t recommend using jQuery-latest to start as you’d have to account for potential deprecation where applicable.