问题:在项目开发时,有时需要获取 冒泡或捕获 过程的所有元素
解决方案:
1、Chrome通过event.path获取:
const ev = window.event || event; const path = ev.path;
2、Firefox和Safari中获取
const ev = window.event || event;
const path = event.composedPath && event.composedPath();
最终解决方案:
const ev = window.event || event;
const path = event.path || (event.composedPath && event.composedPath());
※随手附上应用代码