Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <div class="container" id="randCont">
  2. <button id="randing" onclick="rand()">Узнать судьбу</button>
  3. <div id="one">
  4. <h1>Первый</h1>
  5. <p>Первый текст</p>
  6. </div>
  7. <div id="two">
  8. <h1>Второй</h1>
  9. <p>Второй текст</p>
  10. </div>
  11. <div id="three">
  12. <h1>Третий</h1>
  13. <p>Третий текст</p>
  14. </div>
  15. <div id="four">
  16. <h1>Четвертый</h1>
  17. <p>Четвертый текст</p>
  18. </div>
  19. <div id="five">
  20. <h1>Пятый</h1>
  21. <p>Пятый текст</p>
  22. </div>
  23. </div>
  24.  
  25. var doc, total, div_R, btn, da;
  26. doc = document;
  27. div_R = doc.querySelector("#randCont div");
  28. btn = doc.getElementById('randing');
  29. da = function() {
  30. doc.getElementById('one').style.display = 'none';
  31. }
  32.  
  33. function rand() {
  34.  
  35.  
  36. total = Math.round(Math.random() * 5);
  37.  
  38. switch (total) {
  39. case 1:
  40. doc.getElementById('one').style.display = 'block';
  41. btn.onclick = da;
  42. break
  43. case 2:
  44. doc.getElementById('two').style.display = 'block';
  45. btn.onclick = da;
  46. break
  47. case 3:
  48. doc.getElementById('three').style.display = 'block';
  49. btn.onclick = da;
  50. break
  51. case 4:
  52. doc.getElementById('four').style.display = 'block';
  53. btn.onclick = da;
  54. break
  55. case 5:
  56. doc.getElementById('five').style.display = 'block';
  57. btn.onclick = da;
  58. break
  59. };
  60.  
  61. doc.getElementById('randing').innerText = "Попробовать ещё";
  62.  
  63.  
  64. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement