Answers for "get the element the cursor hovering over"

1

get the element the cursor hovering over

window.addEventListener('click', function(e) {
  var x = e.clientX;
  var y = e.clientY;
  var hoverElement = document.elementFromPoint(x, y);
  console.log(`Hover element is ${hoverElement.tagName}`);
});
Posted by: Guest on October-08-2021

Code answers related to "get the element the cursor hovering over"

Code answers related to "Javascript"

Browse Popular Code Answers by Language