set the height of a div using js to match the bottom position of another div

How about this?

let height = 0
let node = document.querySelector('DIV_N')
while(true) {​​​​
    height += node.getBoundingClientRect().height
    if (node.classList.contains('DIV_1')) break
    node = node.previousSibling
}​​​​
document.querySelector('.DIV_X').style.height = height + 'px'

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top