如何检测到底时溢出的表[jQuery] [英] How to detect table that have overflow when reach bottom [jQuery]

查看:90
本文介绍了如何检测到底时溢出的表[jQuery]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这个带有溢出风格的表元素中创建像无限滚动的UI。所以我可以在到达底部表格时动态添加行。



我们可以做到吗?我会尝试很多脚本,但仍然无法获得表溢出。

  $('#table')。 on('scroll',function(){
if($(this).scrollTop()+ $(this).innerHeight()> = $(this)[0] .scrollHeight){
alert('end reached');
}
})

谢谢提前。

解决方案

您可能必须将 tbody 而不是

https://jsfiddle.net/guanzo/ocfyu8mL/


I want to create UI like infinite scroll inside this table element with overflow style. So I can dynamically adding row when reach bottom table.

Can we do it? I'll try many script but still can't get the end of table overflow.

$('#table').on('scroll', function () {
    if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
        alert('end reached');
    }       
})

Thanks in advance.

解决方案

You may have to set the scroll handler on tbody instead of table.

https://jsfiddle.net/guanzo/ocfyu8mL/

这篇关于如何检测到底时溢出的表[jQuery]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆