Aide animation div javascript
luffy59
-
Brachior Messages postés 613 Date d'inscription Statut Membre Dernière intervention -
Brachior Messages postés 613 Date d'inscription Statut Membre Dernière intervention -
Bonjour, j'essaye de faire bouger mon div au cliquage du bouton input mais celui ci ne bouge pas.
Si je met la variable idTimer dans le body avec pour action onLoad l'animation se fait.
Si quelqu'un pourrai m'aider.
Merci
Script ne marchant pas :
Script qui marche
Si je met la variable idTimer dans le body avec pour action onLoad l'animation se fait.
Si quelqu'un pourrai m'aider.
Merci
Script ne marchant pas :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" media="screen" type="text/css" title="styles" href="css.css" /> </head> <body> <style> #carre { background-color: red; height: 50px; width: 50px; } </style> <script type="text/javascript"> var cursor = 0; function move() { var carre = document.getElementById("carre"); carre.style.marginLeft = 5*cursor + "px"; if (cursor > 50) clearInterval(idTimer); else cursor++; } </script> <div id="carre"></div> <br/> <br/> <input type="button" value="Clique" onClik="idTimer = setInterval('move()', 20);"/> </body> </html>
Script qui marche
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" media="screen" type="text/css" title="styles" href="css.css" /> </head> <body onload = "idTimer = setInterval('move()',20);"> <style> #carre { background-color: red; height: 50px; width: 50px; } </style> <script type="text/javascript"> var cursor = 0; function move() { var carre = document.getElementById("carre"); carre.style.marginLeft = 5*cursor + "px"; if (cursor > 50) clearInterval(idTimer); else cursor++; } </script> <div id="carre"></div> </body> </html>
A voir également:
- Aide animation div javascript
- Telecharger javascript - Télécharger - Langages
- Div c++ - Télécharger - Langages
- Dp animation maker - Télécharger - Animation
- Idée animation anniversaire adulte ✓ - Forum Loisirs / Divertissements
- A javascript error occurred in the main process - Forum Windows