如何在Jquery中检测Div滚动? [英] How Do I Detect A Div Scroll In Jquery?

查看:58
本文介绍了如何在Jquery中检测Div滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Jquery

my Jquery

<script type="text/javascript">
        var pageIndex = 1;
        var pageCount;
        $(".template").scroll(function () {
            if ($(".template").scrollTop() == $(RepDetails).height() - $(".template").height()) {
                GetRecords();
            }
        });
 </script>







我的CSS






My CSS

<style type="text/css">
 template {
            height: 400px;
            overflow-y: scroll;
        }
    </style>







我的html标签






My html Tags

<div id="ScrollDiv" class="template">
                   <table>
                       <tr>
                           <td>
                               <asp:Repeater ID="RepDetails" runat="server" >
                                   <HeaderTemplate>
                                       <%--<table class="httable">
                               <tr>
                                   <td colspan="2">
                                       <b>JOBS</b>
                                   </td>
                               </tr>
                           </table>--%>
                                   </HeaderTemplate>
                                   <ItemTemplate>
                                       <table class="tl">
                                           <tr>
                                               <td><%-- style="border-top-color:#098ABA; border-top-width:thin; border-top-style:solid;"--%>
                                                   <table>
                                                       <tr>
                                                           <td class="ittrjd">
                                                               <asp:Label ID="lblSubject" runat="server" Text='<%#Eval("JobDecription") %>' />
                                                           </td>
                                                       </tr>
                                                   </table>
                                               </td>
                                           </tr>
                                           <tr>
                                               <td class="ittrcn">
                                                   <asp:Label ID="lblComment" runat="server" Text='<%#Eval("CompanyName") %>' />
                                               </td>
                                           </tr>
                                           <tr>
                                               <td style="border-bottom-color: #a9a9aa; border-bottom-width: thin; border-bottom-style: solid;">
                                                   <table>
                                                       <tr>
                                                           <td class="ittre">Experience:&nbsp;&nbsp;<asp:Label ID="lblUser" runat="server" Font-Bold="true" Text='<%#Eval("ExperienceRqrd") %>' /></td>
                                                           <td class="ittre">Salary:&nbsp;&nbsp;<asp:Label ID="lblDate" runat="server" Font-Bold="true" Text='<%#Eval("SalaryOffer") %>' /></td>
                                                       </tr>
                                                   </table>
                                               </td>
                                           </tr>
                                           <%--<tr>
                                   <td colspan="2" style="background-color:white;">&nbsp;</td>
                               </tr>--%>
                                       </table>
                                   </ItemTemplate>
                                   <FooterTemplate>
                                   </FooterTemplate>
                               </asp:Repeater>
                           </td>
                       </tr>
                       <tr>
                           <td>
                               <img alt="" src="images/loadingData.gif" style="display: none" />
                           </td>
                       </tr>
                   </table>
               </div>









i无法检测到div的滚动事件(id = ScrollDiv)



i我正在获取10条记录并将其填充在repeter中(id = RepDetails)和它的工作正常和滚动条也在那里。

使用div中滚动条的css模板。



原始jquery是





i can not detect the scroll event of the div(id=ScrollDiv)

i am fetching 10 record and populate it in the repeter(id=RepDetails) and its workin fine and scrollbar is also there.
use the css template for the scrollbar in the div.

the original jquery was

<script type="text/javascript">
        $(window).scroll(function () {
            if ($(window).scrollTop() == $(document).height() - $(window).height()) {
                GetRecords();
            }
        });
</script>











< br $> b $ b



我为我的project.i确定我的jquery不正确。请帮助我解决问题









which i modified for my project.i am sure that my jquery is not correct.please help me to solve the problem

推荐答案

(。template)。scroll(function(){
if(
(".template").scroll(function () { if (


(。template) .scrollTop()==
(".template").scrollTop() ==


(RepDetails).height() -
(RepDetails).height() -


这篇关于如何在Jquery中检测Div滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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