https://jsfiddle.net/qq3w1k3a/
If the height is set via CSS, you can check the height specified in the styling against the scrollHeight
. a.e the following will alert true
or false
depending on if the supplied element's scroll height is larger than it's specified size.
function check_height(ele) {
let styleHeight = +getComputedStyle(ele).getPropertyValue('height').slice(0,-2);
alert(ele.scrollHeight > styleHeight);
}
Edit: to elaborate on this +getComputedStyle(ele).getPropertyValue('height').slice(0,-2);
getComputedStyle(ele)
is a window method that will, as the name suggests, grab all the styling of the specified element. The returned object has a method called getPropertyValue
that allows you to specify what property you would like to grab(in this case height
).
.slice(0, -2)
is just a normal array method that removes the last two characters of the string. (since strings are just an array of characters this works)
the +
sign in front of all of it is to automatically convert the value to an integer instead of keeping it as a string.