Advertisement
Crevice

handlerExercise3

Nov 6th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. <!--add the script tag and CDN for jquery here-->
  9.  
  10. <script>
  11. $(document).ready(initializeApp)
  12.  
  13. function initializeApp () {
  14. //add a click handler here for the div with an id of clickDiv
  15. //it should call a named function "handleClick" which takes "event" as a parameter
  16. //the function should log out the event object
  17. //(Note the difference between the jquery event object and the event object from
  18. //the previous challenge)
  19. //the "handleClick" function should also call an alert which congratulates you on success
  20. // for a bonus challenge, use jQuery to "toggle" the class of "chartreuse" when the div is clicked
  21. }
  22.  
  23. </script>
  24. <style>
  25. .click-div {
  26. height: 150px;
  27. width: 550px;
  28. display: inline-block;
  29. background-color: lightgray;
  30. text-align: center;
  31. }
  32. p {
  33. font-size: 3rem;
  34. width: 75%;
  35. margin: 0 auto;
  36. border: 1px solid black;
  37. }
  38.  
  39. .click-div, p {
  40. position: absolute;
  41. top: 50%;
  42. left: 50%;
  43. transform: translate(-50%,-50%);
  44. border-radius: 10px;
  45. }
  46.  
  47. .chartreuse {
  48. background-color: chartreuse
  49. }
  50. </style>
  51.  
  52. </head>
  53. <body>
  54.  
  55. <div class="click-div" id="clickDiv">
  56. <p>I am the Click Div</p>
  57. </div>
  58.  
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement