javascript - What make this code to be execute over and over -


i learning js , studying mta exam, not expert can see. don't element makes code execute on , over.

when document loads, init() called, gets element going moved , calls move_par()

and here function moves element until reaches 300. why after executed starts on again?

can help.? thanks

here code

<!doctype html> <html> <head>     <title> animation</title>     <script type="text/javascript">         function move_par() {             current += 1;             if (current > 300) {                 current = 0;             }             par.style.left = current;             var rate = document.getelementbyid("rate").value;             settimeout(move_par, rate);         }         function init() {             par = document.getelementbyid("ori");             par.style.position = "absolute";             current = 0;             move_par();         }     </script>  </head> <body onload="init();">     <h1> animation js</h1>     <form>         <input id="rate" type="number" value="18" min="1" max="100">         </input>     </form>     <p id="ori"> see me  moving?</p>  </body> </html> 

the first animation fired in init() function call move_par(); second animation fired because call function again within settimeout(move_par, rate); wrapper.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -