Options:

Legend:

Nearest to cursor (found two ways)
Furthest from cursor
Nearest to clicked element
Furthest from clicked element
Tolerance for nearest element
Tolerance for furthest element
Back to documentation

A demonstration of the jQuery Nearest Element plugin. Check out the code behind it. Distance line generated with the jQuery DOM Line plugin.