How can I make a textarea automatically expand using jQuery?
I have a textbox for explaining the agenda of the meeting, so I want to expand that textbox when my agenda's text keep growing that textbox area.
How can I make a textarea automatically expand using jQuery?
I have a textbox for explaining the agenda of the meeting, so I want to expand that textbox when my agenda's text keep growing that textbox area.
There is also the very cool
bgrins/ExpandingTextareas (github)
project, based on a publication by Neill Jenkins called Expanding Text Areas Made ElegantI fixed a few bugs in the answer provided by Reigel (the accepted answer):
There are some remaining issues concerning spaces. I don't see a solution for double spaces, they are displayed as single spaces in the shadow (html rendering). This cannot be soved by using , because the spaces should break. Also, the textarea breaks a line after a space, if there is no room for that space it will break the line at an earlier point. Suggestions are welcome.
Corrected code:
Code of SpYk3HH with addition for shrinking size.
The simplest solution:
html:
css:
js (jquery):
Solution with pure JS
https://jsfiddle.net/Samb102/cjqa2kf4/54/
Everyone should try this jQuery plugin: xautoresize-jquery. It's really good and should solve your problem.