给定一个包含
方法一:
- 获取 textarea的 scrollHeight 属性。
- 使用scrollTop 属性使用 jQuery 设置垂直滚动条的位置。
示例:此示例实现了上述方法。
JavaScript | Set textarea scroll
bar to bottom as a default.
GeeksForGeeks
GeeksforGeeks is a Computer Science
portal for geeks. It contains well
written, well thought and well
explained computer science and
programming articles, quizzes etc.
It also contains the practice section
which is helpful for practicing the
data structure and algorithms
questions. GeeksforGeeks provides
placement course, DSA class, Machine
learning class and other online and
offline courses which will help in
placement and also growing the
knowledge.
输出:
- 在点击按钮之前:
- 点击按钮后:
方法二:
- 这个例子通过 JavaScript 完成了同样的工作。
- 获取 textarea的 scrollHeight 属性。
- 使用scrollTop 属性设置垂直滚动条的位置。
示例:此示例实现了上述方法。
JavaScript | Set textarea scroll bar to bottom as a default.
GeeksForGeeks
GeeksforGeeks is a Computer Science
portal for geeks. It contains well
written, well thought and well
explained computer science and
programming articles, quizzes etc.
It also contains the practice section
which is helpful for practicing the
data structure and algorithms
questions. GeeksforGeeks provides
placement course, DSA class, Machine
learning class and other online and
offline courses which will help in
placement and also growing the
knowledge.
输出:
- 在点击按钮之前:
- 点击按钮后: