Advertisement
Guest User

code_animation

a guest
Mar 24th, 2013
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  2. "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <meta charset="UTF-8">
  5.  
  6. <head>
  7.         <title>StarWars</title>
  8.         <script type = "text/javascript">
  9.  
  10.         function move(elem){
  11.             var st=0;
  12.             console.log("ELEM "+elem);
  13.             function animate(){
  14.                
  15.                 st++;
  16.                 console.log(st);
  17.                 elem.style.left = st+'px';
  18.  
  19.                 console.log("elem" + elem.style.left);
  20.                  if (st == 100)  // check finish condition
  21.                       clearInterval(id)
  22.  
  23.             }
  24.  
  25.             id = setInterval(animate, 10);
  26.  
  27.  
  28.         }
  29.  
  30.  
  31.         </script>
  32.  
  33.         <style type="text/css">
  34.  
  35.             body{
  36.                     background-image:url('http://www.solosequenosenada.com/galeria/fondos/bgestels/bgstar17.gif');
  37.            
  38.                 }
  39.  
  40.         </style>
  41.  
  42.  
  43. </head>
  44.  
  45.  
  46. <body>
  47.  
  48. <button onclick="move(text_ex)">Click</button>
  49.    
  50. <div id="text_ex" style="width:100px; height:100px; background-color:red"></div>
  51.  
  52.  
  53. </body>
  54.  
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement