height of textarea increases when value increased but does not reduce when value is decreased

后端 未结 2 1617
情书的邮戳
情书的邮戳 2021-01-19 05:13



        
相关标签:
2条回答
  • 2021-01-19 05:50

    The minimum scrollHeight of a textarea is always going to be the height. To get an accurate scrollHeight, set the height to 1 first.

    h.height(1).height(h[0].scrollHeight);
    

    http://jsfiddle.net/aarongloege/t2vAr/

    0 讨论(0)
  • 2021-01-19 06:07

    If you do not want to code it by yourself, you can also use this script: https://github.com/brandonaaron/jquery-expandable It already contains a nice slide-effect ;-)

    0 讨论(0)
提交回复
热议问题