当前位置:网站首页>Three methods to make the scroll bar of div automatically scroll to the bottom
Three methods to make the scroll bar of div automatically scroll to the bottom
2022-06-13 08:24:00 【tingkeaiii】
Method 1 :
Use the anchor to mark the position to scroll to , And then through click Method to simulate clicking and scrolling to the anchor position
<script language="javascript1.2" type="text/javascript">
function onGetMessage(context)
{
msg.innerHTML+=context;
msg_end.click();
}
</script>
<div style="width:500px;overflow:auto">
<div id="msg" style="overflow:hidden;width:480px;"></div>
<div><a id="msg_end" name="1" href="#1"> </a></div>
</div>Method 2 :
utilize DIV Of scrollIntoView Method , Scroll the bottom end to the visible position [list=1]<script
language="javascript1.2"
type="text/javascript">
function onGetMessage(context)
{
msg.innerHTML+=context;
msg_end.scrollIntoView();
}
</script>
<div style="width:500px;overflow:auto">
<div id="msg" style="overflow:hidden;width:480px;"></div>
<div id="msg_end" style="height:0px; overflow:hidden"></div>
</div>Method 3 :
<script type="text/javascript">
function add()
{
var now = new Date();
var div = document.getElementById('scrolldIV');
div.innerHTML = div.innerHTML + 'time_' + now.getTime() + '<br />';
div.scrollTop = div.scrollHeight;
}
</script>
<span class="notice"> Please click on “ Insert a row ” Button , Insert the latest information , When the scroll bar appears , The scroll bar will automatically remain at the bottom .</span><br />
<div id="scrolldIV" style="overflow:auto; height: 100px; width: 400px; border: 1px solid #999;">
</div>
<input type="button" value=" Insert a row " onclick="add();">边栏推荐
- JS - print 99 multiplication table of the for cycle case
- filebeat采集日志到ELK
- Notes on MySQL transaction not automatically submitting
- Logstash configuration reference article
- Amino encoding protocol
- Edge浏览器如何安装BdTab(BD)新标签页插件(图文教程)
- d3.js&nvd3. JS - how to set the y-axis range - d3 js & nvd3. js — How to set y-axis range
- The method of SolidWorks modifying text font in engineering drawing
- 【完全信息静态博弈-Nash均衡的特性】
- Remote access and control
猜你喜欢
![[game theory complete information static game] Application of Nash equilibrium](/img/22/5fd28415cba6ee67878249b4aabb2e.jpg)
[game theory complete information static game] Application of Nash equilibrium

Introduction to dfinity (ICP) -1

JS - max. of array cases

Start from scratch - implement the jpetstore website -1- establish the project framework and project introduction

CCNP_ BT static routing

Buuctf web (IV)

How to modify desktop path in win10 system

Process and scheduled task management

JS - array de duplication in the array object case

Buuctf web (III)
随机推荐
JS to download files in batches
Data accuracy problems caused by inconsistent data types during sum in MySQL
SQL injection question type (manual injection +sqlmap)
Process and scheduled task management
Microservice Project Construction II: database design
名次的确定
字符串的逆序与比较
Did decentralized digital identity
[complete information static game characteristics of Nash equilibrium]
水仙花升级版(自幂数)
Buuctf web (VI)
Guidance process and service control
IPFs cluster setup process
JS - for cycle case: Horse grain
Batch package and download Alibaba OSS files
使用kvm创建三台能通局域网的虚拟机
LeetCode-按奇偶排序数组
How about a well-known food material distribution information management system?
Dest0g3 520迎新賽
CCNP_ BT static routing