ForeverDev

Untitled

Oct 10th, 2014
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.     <title> Testing stuff </title>
  6. </head>
  7.  
  8. <body>
  9.     <div>
  10.         <img id = "displayDuckImage" height = "100" width = "100" src="http://www.toyhalloffame.org/sites/www.toyhalloffame.org/files/toys/square/rubber-duck_0.jpg" />
  11.         <input id = "changeDuckImage" type = "button" onclick = changeDuck() value = "Click me to change the duck!"</input>
  12.     </div>
  13.  
  14.     <input id = "pickBackgroundColor" value = "#ff0000" type="color" </input>
  15.     <input id = "changeBackgroundColor" type = "button" onclick = changeBackground() value = "Click me to change the background color!" </input>
  16. </body>
  17.  
  18. <style>
  19.  
  20.     body {
  21.         background-image: url("http://cdn.wonderfulengineering.com/wp-content/uploads/2014/01/HD-backgrounds-3.jpg");
  22.     }
  23.  
  24.     input, img {
  25.         display: block;
  26.         margin-right: auto;
  27.         margin-left: auto;
  28.     }
  29.  
  30.     #pickBackgroundColor, #changeBackgroundColor {
  31.         position: relative;
  32.         top: 150px;
  33.         margin-right: auto;
  34.         margin-left: auto;
  35.     }
  36.  
  37. </style>
  38.  
  39. <script>
  40.  
  41.     var images = {
  42.         duckOne : "http://www.toyhalloffame.org/sites/www.toyhalloffame.org/files/toys/square/rubber-duck_0.jpg",
  43.         duckTwo : "http://www.saintpetersblog.com/wp-content/uploads/2014/08/rubber-duck.jpg"
  44.     }
  45.  
  46.     function changeDuck() {
  47.         var display = document.getElementById("displayDuckImage")
  48.         display.src = (display.src == images.duckOne && images.duckTwo || images.duckOne)
  49.     }
  50.  
  51.     function changeBackground() {
  52.         document.body.style.background = document.getElementById("pickBackgroundColor").value
  53.     }
  54.  
  55. </script>
  56.  
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment