Roy*_*gon 33 html javascript jquery
<h2>Greetings</h2>
<div class="container">
<div class="inner">
Hello
<p>Test</p>
</div>
<textarea id="one" class="inner">
Goodbye
</textarea>
</div>
$("#one").append("your text to append");
$("#one").append("your text to append");
$("#one").append("your text to append");
$("#one").append("your text to append");
Run Code Online (Sandbox Code Playgroud)
如何在这个textarea中自动滚动到下方?
Rom*_*lus 58
将此位添加到您的代码中(最好在您拥有的任何插入的末尾):
var psconsole = $('#one');
if(psconsole.length)
psconsole.scrollTop(psconsole[0].scrollHeight - psconsole.height());
Run Code Online (Sandbox Code Playgroud)
Der*_*會功夫 11
看这个现场演示: here
为了计算底部scrollTop
,你可以简单地减去了height
来自scrollHeight
:
var oneDiv = $("#one");
bottom = oneDiv.prop('scrollHeight') - oneDiv.height()
Run Code Online (Sandbox Code Playgroud)
然后你可以设置它的scrollTop bottom
,或者使用惊人的jQueryanimate()
来制作很酷的动画.
现场演示: here
归档时间: |
|
查看次数: |
32674 次 |
最近记录: |