search

Home  >  Q&A  >  body text

javascript - 插入文本到textarea后,自动显示插入的最后一行

看下面的代码,点击【add content】后会在textarea最后一行插入内容,我希望内容超过显示区域后,textarea 自动滚动到最后一行显示。需要加神马呢?

<h2>SAMPLE</h2>
<a href="###" id="add">add content</a>
<br/><br/>

<textarea id="text">
Goodbye
</textarea>
$('#add').click(function() {
    $("#text").append("the text to append \n");
});

http://jsfiddle.net/Sn5Cz/

PHPzPHPz2792 days ago625

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 01:15:17

    javascript - After inserting text into textarea, automatically display the last inserted line - PHP Chinese website Q&A - javascript - After inserting text into textarea, automatically display the inserted last line - PHP Chinese website Q&A

    Take a look around Oh, study it.

    reply
    0
  • 怪我咯

    怪我咯2017-04-10 12:44:33

    http://stackoverflow.com/questions/84...

    http://jsfiddle.net/Sn5Cz/1/

    reply
    0
  • Cancelreply