You don't need to do this in two steps:
var myElementHeight = // code to get element height here
Also, if you put your JS at the bottom of your page, directly before the closing </body> tags, then the page will be loaded by default, so you don't need to wait for it.
The height will be returned in px. Therefore adding ems might cause unexpected results.
I don't understand this.
Apart from the fact that Margin may not be capitalized (I think) and the fact that you are not using the height information you obtained from the first container, this seems reasonable.
I would do it something like:
var myElementHeight = $(selector).cdeToGetHeight
I think that should work.
By the way, I find it great that you're not simply asking for the answer, but trying to understand what is going on.
Feel free to let me know if you need any more guidance with this.