I am trying to add event listeners to two elements, container and archive. They are in this hierarchy - container->timestamp->archive.
I added a event listener to archive button in the following way,
archive.addEventListener('click', ()=>{
console.log("HI");
})
In a similar way, I attached event listener to archive button's parent, container,
container.addEventListener('click', ()=>{
open_email(element.id);
})
Whenever I click on archive button, container's event listener gets triggered which is not desirable. I tried looking up event delegation but didn't get any idea to solve this problem. Any help would be appreciated.