Hi All,
I am trying to understand event capturing and event bubbling. Can you please help me with this issue. I am struck with below piece of code.
My Question is-
Why clicking on “This is a heading” is not giving two alerts? While clicking on some checkbox is giving two alerts.
<body id = "body-id">
<h1>This is a Heading</h1>
<label id="wow"><input type="checkbox" name="checkbox" value="value">Some checkbox</label>
<script>
var fn = function(){
alert("Hello from body tag");
}
var fn1 = function() {
alert("Hello form checkbox");
}
e1.addEventListener("click", fn, false);
var e1 = document.getElementById("body-id");
var wow = document.getElementById("wow");
wow.addEventListener("click", fn1, false);
</script>
</body>