Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. Change the size of the image: Display this image of a turtle. (This is Nickel, the sea turtle who lives in the Caribbean Reef habitat at Shedd Aquarium in Chicago). Have 3 buttons underneath. One should say 'Shrink Image' and should make the image 200x307 (height x width). Another should say 'Enlarge Pic' and make it 400x580. A third should say 'Restore Pic' and make it its original size of 300x460. The code to do each of these should be inside the value of the 'onclick' attribute of the button.
  2.  
  3.  
  4.  
  5. Change the border: Create a class that creates a red, dashed, 5 pixel border. When the user hovers over the picture of the turtle, the class should be applied. When the user moves the mouse off of the turtle, the class should be removed. There are a few ways to do this, but as a hint, let me suggest one possibility: that you use the 'onmouseover' and 'onmouseout' attributes inside the <img> tag that you use to display the turtle.
  6.  
  7.  
  8.  
  9. Change the font: Have a select box with 3 fonts in it: Helvetica, Verdana, Times New Roman. The first option in the box should be 'Select a Font'. Each time the user selects a font, change the text on the page to that font. Invoke the function that does this from the <select> tag. That is, do not use a separate button to invoke the function.
  10.  
  11.  
  12.  
  13. How old will Nickel be? As mentioned earlier, Nickel is Shedd's sea turtle. Nickel is estimated to have been born in 1996 or so. Have a text field that asks the user to enter a year. Then have a button that invokes a function that tells you how old she will be in that year. So if the user enters 2026, you will say: "In 2026, Nickel will be 30 years old!" You should output this using the 'append()' function as a new paragraph at the end of the 'about_turtles' div section.
  14.  
  15.  
  16.  
  17. Incidentally, I feed Nickel during presentations about once a week at Shedd. If any of you are planning on visiting the aquarium, let me know and maybe we can coordinate a visit.
  18.  
  19.  
  20. <html>
  21. <head>
  22. <meta charset="utf-8">
  23. <title>Turtles</title>
  24.  
  25. <style>
  26. img:hover{border: 5px red;
  27. border-style:dashed;
  28.  
  29. }
  30. </style>
  31.  
  32. <script>
  33. function how_old_Nickel()
  34. {
  35. var year=$('#how_old').val()
  36. var answer=Number(year-1996);
  37. $("#about_turtles").append(" In "+ year + " Nickel will be " + answer + " years old");
  38.  
  39.  
  40. }
  41.  
  42. </script>
  43.  
  44. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  45. </head>
  46. <body>
  47. <h2>All About Turtles</h2>
  48. <div id="about_turtles">
  49. <p>Sea turtles (superfamily Chelonioidea), sometimes called marine turtles,[3] are reptiles of the order Testudines and of the suborder cryptodira. The seven existing species of sea turtles are: the green, loggerhead, Kemp's ridley, olive ridley, hawksbill, flatback, and leatherback.[4]
  50. </p>
  51. <p>The majority of a sea turtle's body is protected by its shell. The turtle's shell is divided into two sections: the carapace (the dorsal portion) and the plastron (the ventral portion). The shell is made up of smaller plates called scutes. The leatherback is the only sea turtle that does not have a hard shell. Instead, it bears a mosaic of bony plates beneath its leathery skin.
  52. </p>
  53. <p>In general, sea turtles have a more fusiform body plan than their terrestrial or freshwater counterparts. The reduced volume of a fusiform (tapering at both ends) body means sea turtles can not retract their head, legs, and arms into their shells for protection like other turtles can.[5] However this more stream-lined body plan reduces drag in the water and allows the turtle to swim more easily.
  54. </p>
  55. </div>
  56. <!--End of Div 'about_turtles'-->
  57. <br><br>
  58. How old will Nickel be?
  59. <br>
  60. <input type='text' id="how_old">
  61. <button type="button" id="Calculate" name="Calculate" onclick="how_old_Nickel()">
  62. Calculate
  63. </button>
  64. <br><br>
  65.  
  66. <img src="nickel.jpg" alt="nickel" id="image"><br>
  67.  
  68. <input type="radio" name="size" value="shrink" onclick="$('#image').css('width','307px'); $('#image').css('height','200px');">
  69. Shrink<br>
  70. <!--should make the image 200x307 (height x width)'-->
  71.  
  72. <input type="radio" name="size" value="enlarge" onclick="$('#image').css('width','580px'); $('#image').css('height','400px');">
  73. Enlarge<br>
  74. <!--400x580-->
  75.  
  76. <input type="radio" name="size" value="restore" onclick="$('#image').css('width','460px'); $('#image').css('height','300px');">
  77. Restore
  78. <!--300x460'-->
  79.  
  80. <br>
  81. <br>
  82.  
  83. <select id="text" onclick="$('#about_turtles').css('font-family', $(this).val())">
  84. <option value="Helvetica">Helvetica</option>
  85. <option value="Verdana">Verdana</option>
  86. <option value="Times New Roman">Times New Roman</option>
  87.  
  88. </select>
  89.  
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement