最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery check if any parent div have scroll bar - Stack Overflow

programmeradmin2浏览0评论

I want to check if any parent div have scroll bar in jQuery but I can't find any good example. Here is my code:-

  <div>
     <div class="heading">
        <div class="visitor_profile">
            <div class="visitor_input_con">
            </div>
        </div>
    </div>
</div>

I want to check if any parent of .visitor_input_con has scroll bar here is my jquery code:-

(function($) {
  $.fn.hasScrollBar = function() {
    return this.get(0).scrollHeight > this.height();
  }
})(jQuery);

$('.visitor_input_con').hasScrollBar();

Please help me to solve this issue. Thanks

I want to check if any parent div have scroll bar in jQuery but I can't find any good example. Here is my code:-

  <div>
     <div class="heading">
        <div class="visitor_profile">
            <div class="visitor_input_con">
            </div>
        </div>
    </div>
</div>

I want to check if any parent of .visitor_input_con has scroll bar here is my jquery code:-

(function($) {
  $.fn.hasScrollBar = function() {
    return this.get(0).scrollHeight > this.height();
  }
})(jQuery);

$('.visitor_input_con').hasScrollBar();

Please help me to solve this issue. Thanks

Share Improve this question asked Jan 10, 2015 at 10:33 Umesh SehtaUmesh Sehta 10.7k5 gold badges42 silver badges68 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

you could filter out parents, e.g:

if($('.visitor_input_con').parents().filter(function(){
    return $(this).hasScrollBar();
}).length)
发布评论

评论列表(0)

  1. 暂无评论