Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul>
- <button onclick="myFunction()">Seattle</button>
- <button onclick="randomFunction()">Go to Random Link</button>
- </ul>
- <script>
- function myFunction() {
- document.body.style.backgroundImage = "url(seattle.jpg)";
- }
- function randomFunction(){
- var element = document.getElementsByClassName('link');
- var random = Math.floor(Math.random() * 10);
- window.open(element[random].getAttribute("href"));
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment