I want to detect the presence of a scroll bar in a DIV using jQuery. I was thinking to use $('div').scrollTop()
but that returns 0 in both cases when the scroll bar is at the top and when there is no scroll bar at all.
Any ideas guys?
Assuming overflow
on the div is auto
:
var div= document.getElementById('something'); // need real DOM Node, not jQuery wrapper
var hasVerticalScrollbar= div.scrollHeight>div.clientHeight;
var hasHorizontalScrollbar= div.scrollWidth>div.clientWidth;