0

I want to use event listener (in a dynamic way also called bubble) for the div in the image below and to console.log which li element was clicked.

I heard there is bubble listener that uses event.target.

So far no success, my code:

document.getElementsByTagName('eon-ui-anchor-nav').addEventListener('click', event => { // Step 2
  if (event.target.className === 'eonui-anchor-nav__item') { // Step 3
    console.log(event.target);
  }
});

enter image description here

isherwood
  • 46,000
  • 15
  • 100
  • 132

0 Answers0