Source Code:
(back to article)
Submit
Result:
Report an issue
<div id="outer" onclick="alert('Clicked the DIV!');"> Click me or one of my children: <p id="inner" onclick="alert('Clicked the P!');">Click me!</p> </div> <script> document.getElementById('outer').addEventListener('click', function() { alert('Captured the click on DIV!'); }, true); // Set to true to handle in the capturing phase document.getElementById('inner').addEventListener('click', function() { alert('Captured the click on P!'); }, true); </script>