0

I am trying to create a text area similar to the one at http://snippi.com/. If you type enough that you reach the bottom line (hit enter a lot) then it increases the height of the text area by one 'line-height' (21px on my site).

I believe the best way to do this would be with jQuery but I'm not really sure where to start. Could anyone help? It would be really awesome as well if when you delete a line it 'shrinks' back by one 'line-height' as on http://snippi.com/.

I have had a shot at it and the code is over here on jsFiddle. This is what I have started with:

$('#text').focus(function () {
    // Do something here
});
Benedict Lewis
  • 2,733
  • 7
  • 37
  • 78
  • 1
    Duplicate (of many...), but specifically: http://stackoverflow.com/questions/7745741/auto-expanding-textarea and http://stackoverflow.com/questions/2948230/auto-expand-a-textarea-using-jquery. Please read. If they *don't* answer your question/solve your problem, rephrase your question to explain how they fail for you. – David Thomas Aug 11 '13 at 11:54

1 Answers1

1

I believe Snippi uses something like this. http://www.jacklmoore.com/autosize/

Usage

// Example:
$(document).ready(function(){
    $('textarea').autosize();   
});

Manual Triggering

$('#example').val('New Text!').trigger('autosize.resize');
Ali Gajani
  • 14,762
  • 12
  • 59
  • 100