Place the script at the bottom of your code, right before the end of the body.

Did this answer your question?