I have a click listener attached to my #main
container
main.addEventListener("click", function() {
console.log("clicked main");
});
Within my main container I have an #element also with a click listener
element.addEventListener("click", function() {
console.log("clicked element but dont trigger main click");
});
How do I avoid triggering the #main
click when clicking within #element
?
Fiddle: http://jsfiddle.net/gufo7mmc/1/
Use event.stopPropagation()