1. <div id="parent">parent
    2. <div id="child" style="margin: 100px;">
    3. child
    4. </div>
    5. </div>
    6. <script>
    7. const parent = document.getElementById('parent')
    8. const child = document.getElementById('child')
    9. parent.addEventListener('click', () => {console.log('parent-not-useCapture')})
    10. parent.addEventListener('click', () => {console.log('parent-useCapture')}, true)
    11. child.addEventListener('click', () => {console.log('child-not-useCapture')})
    12. child.addEventListener('click', () => {console.log('child-useCapture')}, true)
    13. </script>

    :::info 点击内部按钮

    “parent-useCapture”
    “child-useCapture”
    “child-not-useCapture”
    “parent-not-useCapture”
    答: 目标元素,事件执行两次,先捕获再冒泡。

    :::