Weird querySelector interaction (not clicking)

47 Views Asked by At

Basically, I have this piece of code:

    if (this.variantId || theme.config.mqlSmall) {
      this.addEventListener('click', this.onHoverHandler.bind(this));
      this.querySelector('a').addEventListener('click', (event) => {
        event.preventDefault();
        console.log("hello")
      });
    }

That should triggers when a color selector get's clicked. It is adding the event listener into my color selector, but it's not triggering :S I'm a little confused about this, never happened to me

This is the structure of my color swatch (this)

Also this is when my event is loaded

I want it to trigger the function when I click on it

0

There are 0 best solutions below