Reputation: 2014
I know you can set the overflow
property in CSS to determine what the page does on overflow, but I was wondering if there was any way to listen for page overflow using pure javascript or jQuery?
Upvotes: 1
Views: 816
Reputation: 41832
You can check by comparing offsetHeight
and scrollHeight
var div = document.getElementById('main');
console.log(div.scrollHeight);
console.log(div.offsetHeight);
The element should have overflow: auto/scroll
css property.
Working Fiddle (add content in the div to check)
Upvotes: 1
Reputation: 4774
You can do it with jQuery
$("element").css("overflow");
or
$("element").css("overflow-x");
I recommend you the 2nd example, because it should work in most browsers.
Upvotes: 0