Why does the js assign a value to the div height to be refreshed before it is displayed?

clipboard.png
js first gets the height of a picture, and then assigns a value to a Div why it is refreshed before it appears, and how to solve the problem and ask for help from passers-by!

Mar.10,2021

can you see if your imgHeight is 0 when it doesn't work? It feels like when performing js, the picture is not loaded and has no height.

Menu