1

テーブルがあり、overflow : auto; を実行してスクロール可能にしました。ページの読み込み時に非表示になっていた次の 5 行を表示できるように、垂直スクロール バーが一番下に達したかどうかを知りたいです。インターネットを検索したところはどこでもwindow.height()を使用しています....しかし、要素がiframe内のテーブルに制限されているため、windowを使用する必要はありません。

ここにテーブル構造があります

 <div class="responsive" style="height:150px; overflow:hidden;" >
   <table class="responsive table table-bordered dataTable" id="checkAllEmail"  >
     <thead>
       <tr style="display:block;">
         <th class="serial" style="width:57px;">#</th>
         <th style="width:156px;">Display Name</th>
         <th class="tableButton" style=" text-align:center!important; width:147px;">Actions</th>
       </tr>
     </thead>
     <tbody id="mailServerTbody" style="height:113px; overflow:auto; display:block;">
     </tbody>
   </table>
 </div>

これが私がjsでやろうとしていることです

$(document).ready(function(){

var div=0;
 $('#mailServerTbody').scroll(function(){
        var temp = $(this).scrollTop();
        console.log($("#mailServerTbody").position().top+"blah")
        console.log(temp)
        if((temp%32==0)||(temp%32==17)){
            console.log("enter")
            div = div+4;
            //div = div*5-1;
            console.log(temp/32+"temp")
            $('#mailServerTbody tr:gt('+div+'):lt(5)').show();
        }
    });
});
4

1 に答える 1

1

これを試して

<script type="text/javascript">
   $(document).ready(function(){
   var tbody = $('#mailServerTbody');
   var heightOfTbody = 0;
   $("#mailServerTbody tr").each(function(){
    heightOfTbody = heightOfTbody + $(this).height();
   });

   $('#mailServerTbody').scroll(function(){

   if(heightOfTbody == ($(this).scrollTop() + $('#mailServerTbody').height() ))
        {
       alert("reached last")
        }
   });
 });
</script>
于 2013-10-21T06:39:28.363 に答える