Got it to work.

The code I was using wasn’t working for some reason and so
I copied some code from W3school and got it to work. I made changes to
the animation itself.