Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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}`);
});
 
PREVIOUS NEXT
Tagged: #element #cursor #hovering
ADD COMMENT
Topic
Name
2+9 =