I have a div with a fixed height and overflow:hidden;
I want to check with jQuery if the div has elements that are overflowing past the fixed height of the div. How can I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You actually don’t need any jQuery to check if there is an overflow happening or not. Using
element.offsetHeight,element.offsetWidth,element.scrollHeightandelement.scrollWidthyou can determine if your element have content bigger than it’s size:See example in action: Fiddle
But if you want to know what element inside your element is visible or not then you need to do more calculation. There is three states for a child element in terms of visibility:
If you want to count semi-visible items it would be the script you need:
And if you don’t want to count semi-visible you can calculate with a little difference.