Edit in JSFiddle

let elements = Array.from(document.querySelectorAll('a'));

let linkCoords = elements.map(link => {
	let rect = link.getBoundingClientRect();
  return [rect.x, rect.y];
});

document.addEventListener("click", ev => {
	let distances = [];
  
  linkCoords.forEach(linkCoord => {
  	let distance = Math.hypot(linkCoord[0]-parseInt(ev.clientX), linkCoord[1]-parseInt(ev.clientY));
    distances.push(parseInt(distance));
  });
  
  let closestLinkIndex = distances.indexOf(Math.min(...distances));
  
  document.getElementById('result').innerHTML = (elements[closestLinkIndex].id);
});