The best way to explain this is using an example:
<div style="width:100px;height:100px;overflow:hidden;">
<?php echo $content; ?>
</div>
How can I use jQuery to see if there's text overflowing?
The best way to explain this is using an example:
<div style="width:100px;height:100px;overflow:hidden;">
<?php echo $content; ?>
</div>
How can I use jQuery to see if there's text overflowing?
Compare the element's scrollHeight
(DOM property, hence .get(0)
) and height
to check whether the contents of an element exceeds the element's boundaries or not.
var $div = $("div"); //Assume one div. Use a more specific selector
var isOverflowing = $div.get(0).scrollHeight != $div.height();
//The variable `isOverflowing` is true if the text overflows