A bit of (JS-modified) HTML might look like this:
<div style="width: 50px;">1,234,567</div>
How do I detect if the text node is wider than the container?
As inspired by How to detect overflow in div element?:
<!-- Overflowing -->
<div style="width: 50px;">1,234,567</div>
<!-- Not overflowing -->
<div>1,234,567</div>
JavaScript (no jQuery) to detect:
var divs = document.getElementsByTagName('div');
var i, div, overflowing;
for (i=0; i<divs.length; i++) {
div = divs[i];
overflowing = div.offsetWidth < div.scrollWidth;
console.log(overflowing);
}
http://jsfiddle.net/mattball/pYj5P/
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