Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="es">
- <head>
- <title>Uso de Temporizadores</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script>
- var position = 0, imagenNodeJS, temporizador;
- function desplazarImagenConTemporizador(){
- imagenNodeJS = document.getElementById('node_js');
- position += 1;
- imagenNodeJS.style.left = position + "px";
- temporizador = setTimeout(desplazarImagenConTemporizador, 50);
- }
- </script>
- </head>
- <body onload="desplazarImagenConTemporizador();">
- <img id="node_js" src="imagenes/node-js.png" style="position: absolute; left: 0;">
- <button onclick="clearTimeout(temporizador);">Cancelar Temporizador</button>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement