textarea高度随文本内容变化,且不出现滚动条

   2019-08-19 15:50:58

javascript css

让文本域的高度随内容的多少而发生改变,且不会产生滚动条。

<textarea type="text" class="textarea_show" id="description" name="description"></textarea>


$('.textarea_show').each(function () {
        this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
    }).on('input', function () {
        this.style.height = 'auto';
        this.style.height = (this.scrollHeight) + 'px';
    });

相关评论:
admin test

靡不有初|  当前时间:  |  网站运行时间:  |鲜克有终

今年剩余【农历】:

粤ICP备19080315号