is it possible to check the overflow:auto from a div?
for example
HTML
<div id="my_div" style="width: 100px; height:100px; overflow:auto;" class="my_class">
* content
</div>
JQUERY
$('.my_class').live('hover', function (event)
{
if (event.type == 'mouseenter')
{
if( ... if scrollbar visible ? ... )
{
alert('true'):
}
else
{
alert('false'):
}
}
});
- Sometimes is the content short (no scrollbar) and sometimes long (scrollbar visible).
Thanks in advance!
Peter
Source: Tips4all
You need element.scrollHeight. Compare it with $(element).height().
ReplyDeleteI should change a little thing of what Reigel said:
ReplyDelete(function($) {
$.fn.hasScrollBar = function() {
return this.get(0).scrollHeight > this.innerHeight();
}
})(jQuery);
innerHeight counts control's height and it's top and bottom paddings
Maybe a more simple solution.
ReplyDeleteif ($(document).height() > $(window).height()) {
// scrollbar
}