Find the elements in a page that are closest to a particular point or element, based on pixel dimensions
JavaScript HTML CSS Makefile
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

jQuery Nearest Element plugin

Full documentation is at


Method signatures:

  • $.nearest({x, y}, selector) - find $(selector) closest to x/y point on screen
  • $(elem).nearest(selector) - find $(selector) closest to elem
  • $(elemSet).nearest({x, y}) - filter $(elemSet) and return closest to x/y point on screen

Reverse logic:

  • $.furthest()
  • $(elem).furthest()


  • $.touching()
  • $(elem).touching()