oracle開啟歸檔以及歸檔空間滿的處理方法
阿新 • • 發佈:2022-04-08
事件冒泡:開始時由最具體的元素接收,讓後逐級向上傳播到DOM最頂層節點
事件冒泡本身的特性,會帶來的壞處,也會帶來的好處,需要我們靈活掌握。
阻止事件冒泡:
標準寫法:利用事件物件裡面的stopPropagation()方法
非標準寫法:IE6-8利用事件物件cancelBubble屬性
程式碼示例:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .father { background-color: pink; width: 500px; height: 500px; } .son { background-color:purple; width: 200px; height: 200px; } </style> </head> <body> <div class="father"> <div class="son">son盒子</div> </div> </body> <script> var son = document.querySelector('.son') son.addEventListener('click', function () { alert('son') // 阻止冒泡 e.stopPropagation(); e.cancelBubble = true; }, false) var father = document.querySelector('.father') father.addEventListener('click', function () { alert('father') }, false) document.addEventListener('click', function () { alert('document') }) </script> </html>