Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to listen to a div overflow event? [duplicate]

Possible Duplicate:
How to detect overflow in div element?

Is there a cross-browser way to listen to div overflow?

Something like: $('#myDiv').bind("divOverflow", function(){alert('div overflowed!')})

like image 622
fortuneRice Avatar asked Dec 13 '25 19:12

fortuneRice


1 Answers

You can do that by comparing scrollHeight with clientHeight.

<script type="text/javascript">
function GetContainerSize ()
{
    var container = document.getElementById ("tempDiv");
    var message = "The width of the contents with padding: " + container.scrollWidth + "px.\n";
    message += "The height of the contents with padding: " + container.scrollHeight + "px.\n";

    alert (message);
}
</script>

For more info: How to detect overflow in div element?

like image 150
Adam Plocher Avatar answered Dec 15 '25 09:12

Adam Plocher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!