Reputation: 35274
If a user types more text than the textarea's area then the textrea gets a scrollbar.
Is there a way to just have the texarea extend so it uses the body's scrollbars?
Is this possible with css? jquery?
Upvotes: 0
Views: 67
Reputation: 318182
Something like this maybe
http://jsfiddle.net/adeneo/cXQVu/
$("textarea").on('keyup', function() {
var rows=$("textarea").val().split('\n').length;
$(this).css('height', rows*20+'px');
});
Upvotes: 0
Reputation: 6406
Possible with jQuery or plain JavaScript.
function resize(){
var ta = $('#ta').get(0);
ta.style.height = (ta.scrollHeight) + 'px';
}
Or:
function resize(){
var ta = document.getElementById('ta');
ta.style.height = (ta.scrollHeight) + 'px';
}
Upvotes: 1