Event Capturing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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