简体   繁体   English

使用 jQuery 或 JavaScript 滚动时,如何在 HTML 表中添加和删除而不影响当前视图中的元素

[英]how to add and remove <tr> in a HTML table without effect on elements in current view when scrolled on them using jQuery or JavaScript

I want to add and remove some row in a table that supports the scrollbar if elements exceed.and when I add or remove some, the current observing be always in the show and prevent them of hiding unless they changed.如果元素超出,我想在支持滚动条的表中添加和删除一些行。当我添加或删除一些时,当前观察始终在显示中并防止它们隐藏,除非它们改变。

https://prnt.sc/s09n7k https://prnt.sc/s09n7k

as I showed in this picture above link, the elements 1~5 are in a show of monitor with desire scrolled.正如我在上面链接中的这张图片中所示,元素 1~5 显示在显示器中,欲望滚动。 0,-1 or 6,7 are hidden in view, and when we remove 0,-1 or 6,7 or when we add another 8th element or -2th element the container has to always show these 1~5 th element that we are scroll on them before and don't affect anything on them unless they themself change. 0,-1 或 6,7 隐藏在视图中,当我们删除 0,-1 或 6,7 或者当我们添加另一个第 8 个元素或第 -2 个元素时,容器必须始终显示这些第 1~5 个元素之前在它们上滚动并且不会影响它们上的任何东西,除非它们自己改变。

thanks.谢谢。

It sounds like you want "infinite scrolling", I suggest having a look in Google for an infinite scrolling library that will work for you.听起来您想要“无限滚动”,我建议您在 Google 中查看适合您的无限滚动库。

It's very hard to implement though and I tend to avoid it in favor of pagination.虽然它很难实现,但我倾向于避免它以支持分页。

There's lots of articles about it:有很多关于它的文章:

And some libraries out there (amongst others):还有一些图书馆(除其他外):

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

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