YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Collecting Click Locations Solution - JavaScript Basics

Get Embed Code
5 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. Okay, so here's the shell of the code that we saw before, where we're
  2. grabbing the click location on the document, which is just the whole website.
  3. And we're going to be running some steps, using this weird function syntax,
  4. that we'll actually be learning a little bit more about soon.
  5. Every time the page is clicked, we create two new variables, x and y.
  6. Both of them use this location object,
  7. this location event object from the click, and we grab its pageX and its pageY,
  8. which are simply the pixel values of the x and y location of the clicks.
  9. Once we have the x and y locations, we simply pass them into logClicks and
  10. we should see, when we click, there it is again, x and y locations.