Resize text area to fit all text on load jquery

后端 未结 7 948
走了就别回头了
走了就别回头了 2020-12-08 06:19

I understand there has been a lot of discussion on this but I have yet to find a solution to fix my needs. Basically I need to autogrow a text area not when you type but on

7条回答
  •  有刺的猬
    2020-12-08 06:52

    This is an workaround.. and maybe an alternative solution:

     $('textarea').each(function(){
        var height = $('')
                     .html($(this).val())
                     .appendTo('body')
                     .height();     
       $(this).css('height',height + 'px');
       $('#my-hidden-div').remove();
    
    });
    

    You can see a demo here http://jsfiddle.net/gZ2cC/

提交回复
热议问题