Just bind a click event to an element, then handle it accordingly... Nothing out of the norms. As an example:
$(el).bind('click', function(event){
var x = event.pageX,
y = event.pageY;
console.log(x + " : " + y); // change to alert to see results with no console
});
You don't have to worry about proper handling of getting the mouse offsets. jQuery fixes it up so you can simple say event.pageX
/event.pageY
to get the position in any browser. In the example above, I just set x and y as local variables, but if you have to use it outside the scope of the callable, you can just make them global. Note that this logs the coordinates to your web console and if you can't access that, change console.log
to something like alert
to make sure everything is working fine.
Edit: After rereading your question, my answer changes:
You can target a specific element by setting it's x and y coordinates using document.elementFromPoint
. It seems supported in major browsers according to this page.