首页 > 解决方案 > 鼠标悬停时如何获取DOM列表?

问题描述

DOM List表示 DOM 序列。比如下图。

在此处输入图像描述

但这仅在 Chrome 中显示。我无法在 Firefox 中找到路径,并且我搜索了很多资料,有人提供以下代码以兼容。

let path = event.path || (event.composedPath && event.composedPath());

但它没有用。那么,有什么建议吗?

$('body')
  .children()
  .mouseover(event => {
    let path = event.path || (event.composedPath && event.composedPath());
    console.log(path); // undefined
  });

Firefox 版本:78.0.2(64 位)

标签: javascriptjqueryfirefoxdom

解决方案


推荐阅读