document.getElementsByClassName(element)
returns a HTMLCollection
of elements. The collection doesn' t have an offsetHeight
property, each element in the collection has.
Now if you want to get the offsetHeight
of the first matched element you can simply use
document.getElementsByClassName(element)[0].offsetHeight
If you wanted the max or min offsetHeight
of all the matched elements you'd need to iterate over the collection.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…