SOURCE

console 命令行工具 X clear

                    
>
console
(async () => {
  console.log('hello')
  await sleep(2000) // 等待两秒
  console.log('world')
})()

function sleep(delay) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            console.log(11); 
            resolve(); 
        } , delay)
    })
}


window.addEventListener('click', (e) => {
    let targetNode = e.target
    while (targetNode !== document) { // 只要当前节点不是最外层document
        console.log(targetNode)
        if (targetNode.getAttribute('data-href')) { //  其实用hasAttribute更合适
            window.open(targetNode.dataset.href)
            break
        } else { // 没找到就继续往上找
            targetNode = targetNode.parentNode
        }
    }
})
<div>
    <a href='' data-href='https://www.baidu.com/' >href</a>
</div>
div {
    width: 100px;
    height: 100px;
    background: pink;
}