WP Bakery WordPress set height from element to height of another element

I’m trying to set an element at the same height of another element.
So I thought using this method it should work:

window.addEventListener('load', function() {
   var sliderHeight = document.querySelector('.slider').offsetHeight;
   document.querySelector('#alles').style.height = sliderHeight + "px";
});

How’s it possible that this doesn’t work? And is there another way achieve what I want?