Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.92 KB | None | 0 0
  1. <body>
  2. <p id="kort"></p>
  3. Kort kvar = <p id="kort2"></p><br>
  4.    
  5. <input type="button" value="Reset" onClick="document.location.reload(true)">  
  6. <button type="button" onClick=(next_card())>Nästa kort!</button>
  7. <button type="button" onClick=(show_card())>Visa kort</button>
  8.    
  9. <br>
  10.        
  11. <script>
  12.    
  13. var myArray = [2, 3, 4, 5, 6, 7, 8, 9, 10, "Knekt", "Dam", "Kung", "Ess"];
  14.         myArray.sort(function() {return 0.5 - Math.random()});
  15.         document.getElementById("kort").innerHTML = myArray[0];  
  16.         document.getElementById("kort2").innerHTML = myArray.length;
  17.        
  18. function next_card()
  19.         {
  20.             myArray.shift();
  21.             document.getElementById("kort").innerHTML = myArray[0];
  22.             document.getElementById("kort2").innerHTML = myArray.length;
  23.            
  24.         }
  25. function show_card()
  26.         {
  27.             window.alert(myArray.length);
  28.         }
  29. </script>
  30.  
  31. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement