How to check if scrollbar exists?


   //THIS FUNCTION IS A SMALL PLUGIN TO CHECK IF SCROLLBAR EXISTS FOR AN ELEMENT
   (function($) {
        $.fn.hasScrollBar = function() {
            return this.get(0).scrollHeight > this.innerHeight();
        }
   })(jQuery);

   //HERE USING THE FUNCTION WE CHECK IT
   if( $('body').hasScrollBar() ) {
      alert('Yes it exists');
   }

Latest Comments

Leave a Reply

comment on this article