What I’m trying to do is make a grid of invisible coordinates on the page equally spaced. I then want a <div> to be placed at whatever grid coordinate is closest to the pointer when onclick is triggered. Here’s the rough idea:
I have the tracking of the mouse coordinates and the placing of the <div> worked out fine. What I’m stuck with is how to approach the problem of the grid of coordinates.
First of all, should I have all my coordinates in an array which I then compare my onclick coordinate to?
Or seeing as my grid coordinates follow a rule, could I do something like finding out which coordinate that is a multiple of whatever my spacing is is closest to the onclick coordinate?
And then, where do I start with working out which grid point coordinate is closest? What’s the best way of going about it?
Thanks!

I was initially writing an answer similar to bobince’s, but he got there before me. I like that way of doing it, but his version has got some floors (though it’s still a very good answer).
I presume that what you want is a HTML-less grid (that is, without markup like a table), which bobince supplies a solution for. In that case, the code may be optimised significantly for cross browser compatibility, readability, errors and speed.
So, I suggest the code should be more like this:
The mouseCoordinate() function is a boiled down version of these two functions:
I really like the idea of your project, perhaps I’ll make something similar myself 😀