There are many ways to animate the div, I will leave that exercise to you. In this case all you have to do is wire up the event properly and there are many ways to do so. Please look at following fiddle. This may not fit to your need entirely but it may give you some idea.
Also look at following methods and see how it works in detail.
setInterval
setTimeout
2
solved Moving object at the same time [closed]