Advertisement
1xptolevitico69

Onclick do keyframes

Jul 10th, 2020
1,556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.70 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width">
  7. <style>
  8.  
  9.  
  10. #red {
  11.   border: 40px solid red;
  12.   display: inline-block;
  13.   cursor:pointer;
  14. }
  15.  
  16. @keyframes anime {
  17.   100% {
  18.     margin-left: 300px;
  19.   }
  20. }
  21.  
  22. </style>
  23. </head>
  24. <body>
  25.  
  26.  
  27.  
  28. <div id='red'></div>
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. <script>
  37.  
  38. i=0;
  39.  
  40.  
  41. red.onclick=function(){
  42. x = prompt('Keyword please');
  43. if(x == 'ciao'){
  44. red.style.animation='anime 3s linear forwards';
  45. }else if(i == 0){
  46. alert('Wrong keyword\nYou have only one more chance left');
  47. i++;
  48. }else if(i == 1){
  49. alert('Oops!');
  50. red.style.display='none';
  51. }
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. </script>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement