Exercise 2Try creating a click event for div tags by adding the following code to an HTML page:
Download the starting files for exercise 2
Challenge A: Implement the code above for a "div" click event, then test the results in a browser
Challenge B: Add an id or class selector to an element in your HTML
Change the jQuery selector "div" to match your selector, eg "#my_unique_id"
Challenge C: Change the event from "click" to one that will only trigger when the user mouses over top of the element. Use this list of jQuery events Link jQuery events
Note there is more than one event that might work in this case. are some better than others?
Add a new tag of your choosing. Assign it a new class or id. Add another jQuery click event to make an alert popup if the user clicks this tag.
Bonus Challenge D: investigate the event.pageX and event.PageY events. Use them to change the alert message so that it reports exactly where the mouse was clicked
Download a sample solution