📜  获取光标悬停的元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:19.302000             🧑  作者: Mango

代码示例1
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}`);
});