function clickAiSendDescription() { $('#id-listing-settings').on('click', '.sell-description-click-for-ai', function (e) { let head_box_div = $('#id-listing-settings').find('#textarea-edit'); let domain_id = $(this).data('domain-id'); let data = {}; let url = window.location.pathname; data.send_ai = 'send_ai'; data.domain_id = domain_id; data.question_id = 1; data.question_style_id = -1; $.ajax({ url: url, type: 'POST', data: data }).done(function (responseData) { let json = JSON.parse(responseData); if (json.code === '0') { let text = $(json.message).text(); head_box_div = head_box_div.scrollTop(head_box_div[0].scrollHeight); printTextVerbatim(head_box_div.children(), text); } }) e.stopPropagation(); }) }. 这段代码可以实现文本域随着文本滚动到最下面吗
时间: 2024-02-14 17:10:35 浏览: 207
这段代码有一点小问题,您可以将这一行:
```
head_box_div = head_box_div.scrollTop(head_box_div[0].scrollHeight);
```
改为:
```
head_box_div.scrollTop(head_box_div[0].scrollHeight);
```
即可实现文本域随着文本自动滚到最下面。完整的修改后的代码如下所示:
```javascript
function clickAiSendDescription() {
$('#id-listing-settings').on('click', '.sell-description-click-for-ai', function (e) {
let head_box_div = $('#id-listing-settings').find('#textarea-edit');
let domain_id = $(this).data('domain-id');
let data = {};
let url = window.location.pathname;
data.send_ai = 'send_ai';
data.domain_id = domain_id;
data.question_id = 1;
data.question_style_id = -1;
$.ajax({
url: url,
type: 'POST',
data: data
}).done(function (responseData) {
let json = JSON.parse(responseData);
if (json.code === '0') {
let text = $(json.message).text();
head_box_div.scrollTop(head_box_div[0].scrollHeight);
printTextVerbatim(head_box_div.children(), text);
}
})
e.stopPropagation();
})
}
```
希望能对您有所帮助。
阅读全文