Advertisement
Fhernd

desplazar-imagen.html

May 30th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="es">
  3.     <head>
  4.         <title>Uso de Temporizadores</title>
  5.         <meta charset="UTF-8">
  6.         <meta name="viewport" content="width=device-width, initial-scale=1">
  7.         <script>
  8.             var position = 0, imagenNodeJS, temporizador;
  9.  
  10.             function desplazarImagenConTemporizador(){
  11.                 imagenNodeJS = document.getElementById('node_js');
  12.                 position += 1;
  13.                 imagenNodeJS.style.left = position + "px";
  14.                 temporizador = setTimeout(desplazarImagenConTemporizador, 50);
  15.             }
  16.         </script>
  17.     </head>
  18.     <body onload="desplazarImagenConTemporizador();">
  19.         <img id="node_js" src="imagenes/node-js.png" style="position: absolute; left: 0;">
  20.         <button onclick="clearTimeout(temporizador);">Cancelar Temporizador</button>
  21.     </body>
  22. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement