Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. meu javascript
  2. let valores = ['maçã', 'banana', 'cereja', '7'];
  3.  
  4. let label1 = document.querySelector('#label1');
  5. let label2 = document.querySelector('#label2');
  6. let label3 = document.querySelector('#label3');
  7.  
  8. label1 = valores[Math.round(Math.random()*3)];
  9. label2 = valores[Math.round(Math.random()*3)];
  10. label3 = valores[Math.round(Math.random()*3)];
  11.  
  12. function sorteio(bloco) {
  13. if(bloco == valores[0]){
  14. bloco = style.backgroundImage = "url('img/maca.png')";
  15. }if(bloco == valores[1]){
  16. bloco = style.backgroundImage = "url('img/banana.png')";
  17. }if (bloco == valores[2]) {
  18. bloco = style.backgroundImage = "url('img/cereja.png')";
  19. }else {
  20. bloco = style.backgroundImage = "url('img/sete.png')";
  21. }
  22. }
  23.  
  24. meu html
  25.  
  26. <html>
  27. <head>
  28. <title>Sorteio</title>
  29. <script src="scripts.js"></script>
  30. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  31. <link rel="stylesheet" type="text/css" href="style.css">
  32.  
  33. </head>
  34. <body>
  35.  
  36. <div class="card c1">
  37. <img class="card-img" src="img/maquina.png">
  38. <div class="card-img-overlay">
  39. <a href="#">
  40. <div id="botaoSort">
  41. </div>
  42. </a>
  43. <div class="pai">
  44. <div class="sorteio" id="label1" onclick="sorteio('label1')"> </div>
  45. <div class="sorteio" id="label2" onclick="sorteio('label1')"> </div>
  46. <div class="sorteio" id="label3" onclick="sorteio('label1')"> </div>
  47. </div>
  48.  
  49. </div>
  50. </div>
  51. </body>
  52. </html>
Add Comment
Please, Sign In to add comment