【发布时间】:2017-05-15 10:35:40
【问题描述】:
看看这个小提琴 https://jsfiddle.net/wzwaj0k0/1/
我想在滚动条到达末尾但无法触发时触发警报
JS
function GetScrollerEndPoint()
{
var scrollHeight = $("#Mytable").prop('scrollHeight');
var divHeight = $("#Mytable").height();
var scrollerEndPoint = scrollHeight - divHeight;
var divScrollerTop = $("#Mytable").scrollTop();
if(divScrollerTop === scrollerEndPoint)
{
alert("you reached the end");
}
}
CSS
table {
display: block;
height: 100px;
overflow-y: auto;
}
table.GeneratedTable thead {
background-color: #959595;
}
HTML
<table id="Mytable" >
<thead>
<tr>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
<td>Cell</td>
</tr>
</tbody>
</table>
什么都试过了。但它应该只是那个表,因为我尝试使用 window.scroll 函数它的工作,但我必须通过 ajax 将行添加到这个表。所以需要在只有表格滚动条到达末尾时去函数
【问题讨论】:
标签: javascript jquery html css