Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2017 13:20
  • 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
What would you like to do?
Event Bubbling
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Event Bubbling</title>
<div id="parent">
<button id="child">Child</button>
var parent = document.querySelector('#parent');
<!-- Add click event on parent div -->
parent.addEventListener('click', function(){
console.log("Parent clicked");
var child = document.querySelector('#child');
<!-- Add click event on child button -->
child.addEventListener('click', function(){
console.log("Child clicked");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment