How to give one element the height of another element in vanilla JavaScript?

How to give one element the height of another element in vanilla JavaScript?

Should this pattern be good?

const outer = document.querySelector("#x");
const inner = document.querySelector("#y")
outer.style.height = inner.style.height;

When it comes to presentation such as that, I’ve found that JavaScript is almost exactly the worst way to do things. It’s done with CSS instead for good reason.

4 Likes

Once again that is not going to do what you expect and not something you need to do as css will do that for you anyway if coded properly. You can’t just throw heights on elements as that means they can’t grow and content will be cut off.

You still seem to be chasing a solution for a problem that we can’t really grasp. Your answer will most likely lie elsewhere as already mentioned in your other threads. I know this is frustrating for you but until we see a demo of the problem you want to solve you will be going around in circles as you are using methods that can’t possibly work in any usable way.

Is this still based on your iframe thread?

1 Like

Yes,

Sadly I still didn’t figure out what is the particular problem I am coping with :sweat_smile:

As soon as I do that, I might even solve it myself and gladly share what actually happened :slight_smile:

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.