前端于我
记录 / js / composedPath

event.composedPath事件记录

获取事件的路径,即具体元素到window对象的路径

例如:

<html>
    <body>
        <button>click</button>
    </body>
</html>
document.querySelector('button').onclick = function(e) {
    console.log(e); // [button, body, html, window]
};

兼容性: chrome > 53, ie不支持, safari > 10, firefox > 52

发表于: 2019-12-27