Skip to content

Instantly share code, notes, and snippets.

@imvsharma
Created December 23, 2017 16:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save imvsharma/760db38d6871d16c8f60401b790f6314 to your computer and use it in GitHub Desktop.
Event Capturing
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Event Capturing</title>
</head>
<body>
<div id="parent">
<button id="child">Child</button>
</div>
<script>
var parent = document.querySelector('#parent');
var child = document.querySelector('#child');
parent.addEventListener('click', function(){
console.log("Parent clicked");
},true);
child.addEventListener('click', function(){
console.log("Child clicked");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment