设置 textarea 默认滑动到底部

转载

原文地址:cnblogs.com/hzj680539/p/5047342.html

javascript:

1
2
var textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight;

 jQuery:

1
2
3
$(document).ready(function(){
    $('#textarea_id').scrollTop($('#textarea_id')[0].scrollHeight);
});

如果发现无法彻底滚动到底部,可以设置textAreapaddingn-bottom值

 

javascript:

1
2
var textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight;

 jQuery:

1
2
3
$(document).ready(function(){
    $('#textarea_id').scrollTop($('#textarea_id')[0].scrollHeight);
});
posted @ 2020-03-25 15:06  远洪  阅读(1182)  评论(0)    收藏  举报