-3

I just would like to know if there is a way to check if a div with the overflow hidden attribute can be checked to see if it has content overflowing it or not. Jquery

0

1 Answer 1

0

Try this....

if (element.offsetHeight < element.scrollHeight ||element.offsetWidth < element.scrollWidth) {
     // your element have overflow
 } else {
  // your element doesn't have overflow
 }

or

if ($("#myoverflowingelement").prop('scrollWidth') > 
 $("#myoverflowingelement").width() ) {
  alert("this element is overflowing !!");  
}
else {
  alert("this element is not overflowing!!"); 
}

refer this link Check with jquery if div has overflowing elements

Sign up to request clarification or add additional context in comments.

6 Comments

this did not work
I dont have a scrollheight as I am using overflow is hidden
try to give correct id to your element and element name... # means element id
Yeah, ive tried that, ive given class name
var invisibleItems = []; for(var i=0; i<element.childElementCount; i++){ if (element.children[i].offsetTop + element.children[i].offsetHeight > element.offsetTop + element.offsetHeight || element.children[i].offsetLeft + element.children[i].offsetWidth > element.offsetLeft + element.offsetWidth ){ invisibleItems.push(element.children[i]); } }
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.