Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="container" id="randCont">
- <button id="randing" onclick="rand()">Узнать судьбу</button>
- <div id="one">
- <h1>Первый</h1>
- <p>Первый текст</p>
- </div>
- <div id="two">
- <h1>Второй</h1>
- <p>Второй текст</p>
- </div>
- <div id="three">
- <h1>Третий</h1>
- <p>Третий текст</p>
- </div>
- <div id="four">
- <h1>Четвертый</h1>
- <p>Четвертый текст</p>
- </div>
- <div id="five">
- <h1>Пятый</h1>
- <p>Пятый текст</p>
- </div>
- </div>
- var doc, total, div_R, btn, da;
- doc = document;
- div_R = doc.querySelector("#randCont div");
- btn = doc.getElementById('randing');
- da = function() {
- doc.getElementById('one').style.display = 'none';
- }
- function rand() {
- total = Math.round(Math.random() * 5);
- switch (total) {
- case 1:
- doc.getElementById('one').style.display = 'block';
- btn.onclick = da;
- break
- case 2:
- doc.getElementById('two').style.display = 'block';
- btn.onclick = da;
- break
- case 3:
- doc.getElementById('three').style.display = 'block';
- btn.onclick = da;
- break
- case 4:
- doc.getElementById('four').style.display = 'block';
- btn.onclick = da;
- break
- case 5:
- doc.getElementById('five').style.display = 'block';
- btn.onclick = da;
- break
- };
- doc.getElementById('randing').innerText = "Попробовать ещё";
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement