Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width">
- <title>Cats</title>
- <link rel="stylesheet" href="">
- </head>
- <body>
- <button onclick = "chooseCat();">Click me =^^=</button>
- </body>
- <script>
- var catBase = {
- address: ['http://www.morefunkyfun.com/latter_images/261903948Whoever-woke-me-up-is-going-to-die-cute-cat-kitty-funny-meme.jpg',
- //'2.jpg',
- 'https://s-media-cache-ak0.pinimg.com/236x/20/78/7a/20787a56c6df78828b184e1dbd58fc00.jpg',
- //'4.jpg',
- 'https://imgs.xkcd.com/comics/fourier.jpg'],
- text: ['First cat\n',
- 'Second cat\n',
- 'Third cat\n']
- //'Fourth cat\n',
- //'Fifth cat\n',
- //'Sixth cat\n'],
- }
- function chooseCat() {
- var input = prompt("Enter 1-3 to see a cat");
- --input;
- showCat(input);
- }
- function showCat(id) {
- /*var img = document.hasOwnProperty("img");
- document.write("meow0");
- if(img != undefined) {
- document.write("meow1");
- img = document.getElementById("img");
- img.parentNode.removeChild(img);
- }
- document.write("meow2");*/
- var img = document.createElement("img");
- img.src = catBase.address[id];
- document.body.appendChild(img);
- alert(catBase.text[id]);
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement