I want to crop text and found ways to do that. The problem is they work on height and i don't know the height because the heading above can have 1, 2, 3... lines.
So i need to get the height of the outer element and subtract the heading height.
var list = document.body.getElementsByClassName("cropText");
for (var i = 0; i < list.length; i++) {
cropTextToFit(list[i]);
}
function cropTextToFit (o) {
var containerHeight = o.clientHeight;
var head = document.getElementsByTagName("H2");
var headHeight = head.clientHeight;
console.log(containerHeight);
console.log(headHeight);
}
cropText is the article tag where the heading and the paragraph are in.
headHeight shows "undefined" and "containerHeight" is wrong...