A simple animation effect implemented by native javascript, implemented by javascript
This article introduces an animation implemented by javascript. Click Start to move the div to the right. After you click STOP, The div stops moving, and then click continue to move. See the following code.
<! DOCTYPE html>
Code explanation:
1. window. onload = function () {}, when the content of the document is fully loaded, run the code in the function.
2. var mydiv = document. getElementById ("mydiv") to obtain the element whose id attribute value is mydiv.
3. var start = document. getElementById ("start") to obtain the element whose id attribute hi is start.
4. var stopmove = document. getElementById ("stopmove") to obtain the element whose id attribute value is stopmove.
5. mydiv. style. left = x + "px", set the left attribute value of the div.
6. start. onclick = function () {}, Register The onclick event handler function for the start element.
7. clearInterval (flag): stop the timer function. If one party clicks the start button multiple times, the overlay effect is displayed.
8. flag = setInterval (move, 20) to start motion.
One simple animation effect implemented by the above native javascript is all the content shared by the editor. I hope to give you a reference and support for the help house.