1. <div id="parent">
    2. <div id="child">
    3. </div>
    4. </div>
    1. <script>
    2. var parent =document.getElementById("parent");
    3. var child = document.getElementById("child")
    4. parent.onclick = function(event){
    5. alert("parent");
    6. // event.stopPropagation();
    7. }
    8. child.onclick = function(event){
    9. alert("child")
    10. event.stopPropagation();
    11. }
    12. /* 如何阻止 event.stopPropagation(); */
    13. </script>