JavaScript to implement div scrolling automatically scroll to the bottom of the code _javascript tips

Source: Internet
Author: User
Query the relevant information, Div does not automatically scroll properties, can only simulate the scrolling mouse to the actual desired effect.

The crucial part is here: Div.scrolltop = div.scrollheight;

The following is a detailed implementation of the streamlined code:
Copy Code code as follows:

<body>
<div id= "Divdetail" style= "overflow-y:scroll; width:250px;height:200px; " >
<table style= "border:1px solid; ">
<tr><td>id</td><td>name</td><td>age</td><td>memo</td> </tr>
<tr><td>000001</td><td>name1</td><td>24</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000002</td><td>name2</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000003</td><td>name3</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000004</td><td>name4</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000005</td><td>name5</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000002</td><td>name2</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000003</td><td>name3</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000004</td><td>name4</td><td>23</td><td> Memomemomemomemomemo</td></tr>
<tr><td>000005</td><td>name5</td><td>23</td><td> Memomemomemomemomemo</td></tr>
</table>
</div>
</body>
<script type= "Text/javascript" defer>
var div = document.getElementById (' Divdetail ');

Div.scrolltop = Div.scrollheight;
alert (div.scrolltop);
</script>

In fact, the implementation is very simple but generally rarely have this demand, during the period or some detours.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.