Skip to content Skip to sidebar Skip to footer

Function Doesn't Correctly Perform Unless It Is Called Twice

Some background: I am using JavaScript to vertically center child divs that vary in height depending on conditions in their parent div. The centering function is as follows: functi

Solution 1:

It's most likely because your images aren't loaded fully at the time you call the center function.

Add an event listener to the images so that the center function fires when the images are loaded.

As for semicolons. Put them in, always. Look up semicolon insertion.


Post a Comment for "Function Doesn't Correctly Perform Unless It Is Called Twice"