Pass argument to an eventListener

PHOTO EMBED

Sat Oct 01 2022 07:10:05 GMT+0000 (UTC)

Saved by @Kristi #javascript

//Menu Fade Animation
const handleHover = function (e) {
  if (e.target.classList.contains('nav__link')) {
    const link = e.target;
    const siblings = link.closest('.nav').querySelectorAll('.nav__link');
    const logo = link.closest('.nav').querySelector('img');

    siblings.forEach(el => {
      if (el !== link) el.style.opacity = this;
    });
    logo.style.opacity = this;
  }
};

//Passing "argument" into handler
nav.addEventListener('mouseover', handleHover.bind(0.5));
nav.addEventListener('mouseout', handleHover.bind(1));
content_copyCOPY

https://www.udemy.com/course/the-complete-javascript-course/learn/lecture/22648983#questions