Difficulty assigning CSS DOM to variables to adjust CSS properties

Hey Code Campers!!

I’m trying to understand the HTML/CSS DOM and how JavaScript can be used with it.

I have set up a test in this example, with two divs (#First-Box, #Second-Box).


I’ve first assigned the two divs to “Let” variables, and the offSetHeight of “#Second-Box” to a variable as well (testProp).

I have then tried to assign the testProp variable to the CSS style property “height” of “#First-Box”, so the two divs
should hypothetically be the same height after the function, although it doesn’t seem to happen. The command I’ve added to change the background color does work though.

I have a feeling I’m missing something regarding how to handle assigning CSS DOM to JavaScript variables.
Is there something I need to change or something about the language I’m not getting?

Feel free to link me to a relevant forum post, or let me know if you need any more information, I appreciate the help, thanks.

offSetHeight != offsetHeight

Use console.log to identify what is assigned to the div.

It’s something I really want to try, but for some reason it gives me no log entry, am I missing something? Just updated it with the console.log entry.

Oh I see, just got an “undefined” value not sure why, is it due to it not being defined previously? I’ll take another look at it myself.

You read the second line, now focus on the first line of my previous answer.

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