How can I check if a scrollbar is visible?

后端 未结 19 2876
情话喂你
情话喂你 2020-11-22 14:39

Is it possible to check the overflow:auto of a div?

For example:

HTML

19条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 15:24

    I should change a little thing of what Reigel said:

    (function($) {
        $.fn.hasScrollBar = function() {
            return this[0] ? this[0].scrollHeight > this.innerHeight() : false;
        }
    })(jQuery);
    

    innerHeight counts control's height and its top and bottom paddings

提交回复
热议问题