CSS:
.blue { width:200px; height:200px; background-color:blue; color:#000000; overflow:auto; }
JavaScript:
function addChar() { $('.blue').append('some text '); }
HTML:
<div id='blue1' class="blue"></div><br /> <a href='javascript:void(0)' onclick='addChar()'>Add</a>
div id='blue1'
has overflow
property set to auto
. I want to detect overflow when it happens.
Definition of jQuery offsetHeight. In jQuery, we can get the height of an element by using the offsetheight property in it. It is an in-built property of jQuery we can use it directly to get the viewable height of an element.
In CSS, overflow refers to any content that is too big for an element's box. This occurs when a block element has a specified height that's too small for the content it contains. You can use the CSS overflow property to control what happens to the overflow.
$.fn.HasScrollBar = function() { //note: clientHeight= height of holder //scrollHeight= we have content till this height var _elm = $(this)[0]; var _hasScrollBar = false; if ((_elm.clientHeight < _elm.scrollHeight) || (_elm.clientWidth < _elm.scrollWidth)) { _hasScrollBar = true; } return _hasScrollBar; }
/// this is my solution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With