简体   繁体   English

jQuery:使用特定的DOM滚动

[英]jquery: scroll with specific DOM

Usually when I insert an element into DOM, the page will not automatically scroll. 通常,当我将元素插入DOM时,页面不会自动滚动。 For example, at first there are divs A B D on page, and the browser view is on D . 例如,首先页面上有div A B D ,浏览器视图在D

A
B
D ] <= browser view

Then I insert C between B and D . 然后我在BD之间插入C The browser view now is on C . 现在,浏览器视图位于C

A
B
C ] <= browser view
D

But I hope it on D. How could I make browser automatically scroll when inserting elements by javascript(but users can still scroll freely)? 但是我希望它在D上。当使用javascript插入元素时,如何使浏览器自动滚动(但用户仍然可以自由滚动)?

if you using jquery then trigger a scroll on the specific DOM element when your new DOM; 如果您使用jquery则当您使用新的DOM时,将触发特定DOM元素上的滚动 C added. C添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM