Thursday, May 15, 2014

How to check whether scrollbar available Using JQuery

In my Example I have a DIV contains some data Table.


As the application looks like Excel, I have to check whether the div have horizontal or Vertical Scrollbar present to set the size of other Div.




JQuery Code is as folows:

       if($('div.dataTableDiv').width()<$('#dataTable').width())
             console.log('Horizontal Scrollbar Present');
       else
             console.log('Horizontal Scrollbar NOT Present');


For Vertical Scrollbar:


       if($('div.dataTableDiv').height()<$('#dataTable').height())
             console.log('Vertical Scrollbar Present');
       else
             console.log('Vertical Scrollbar NOT Present');