If I set a fixed width in a textarea element, is there an elegant way to set the default height to a size that would allow all the content to fit?
I was hoping to avoid hard coding anything in jquery that would compare text.length and try to equate the value to the height, but maybe this is the only way I would like to see some kind of css rule of my own, if possible but I can't think nothing about the head.
I created a fiddle illustrating what I'm trying to accomplish.
http://jsfiddle.net/edZgm/
here is the code:
CSS
textarea {
overflow: hidden;
}
JQuery:
$('document').ready(function () {
$('textarea')
.width(500);
});
HTML:
<textarea> ... lots of text </textarea>
Thanks in advance.
source
share