Hello.

It is necessary to track where the user clicks. Those. not just click on any element - but on the whole document, and you need to save the coordinates. For example, I clicked in the upper left corner - the function should return the value 1: 1, or something like that.

Is it possible to implement this?

UPD: Solution

var coords = {}, i = 0; $(document).click(function(e){ coords[i++] = {'x':e.pageX,'y':e.pageY}; $('body').text( JSON.stringify(coords) ); }); 
  • hang event on document - zb '

1 answer 1

For example, in this way .

  • Slightly redid your example, but thanks, that's right :) I will add the solution to the question text. - andrewshka