How to check if a DIV is scrolled all the way to the bottom with jQuery

后端 未结 8 518
盖世英雄少女心
盖世英雄少女心 2020-12-08 00:27

I have a div with overflow:scroll.

I want to know if it\'s currently scrolled all the way down. How, using JQuery?

This one doesn\'t work: How can I determin

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 00:59

    Since it works without jQuery like that :

     var isBottom = node.scrollTop + node.offsetHeight === node.scrollHeight;
    

    I do :

     var node = $('#mydiv')[0]; // gets the html element
     if(node) {
        var isBottom = node.scrollTop + node.offsetHeight === node.scrollHeight;
     }
    

提交回复
热议问题