// SNS리스트 호버 이벤트(백그라운드 이미지) const snsKind = ['insta', 'face', 'blog', 'youtube'] const ON = "on" const OFF = "off" // listArray = 리스트 DOM이 담긴 배열 const snsBg = (listArray) => { if (listArray) { listArray.forEach((element, index, array) => { element.style.background = `url('./main/icon/sns_${snsKind[index]}_${OFF}.png') no-repeat` }) } } const mouseEnter = (listArray) => { listArray.forEach((element, index, array) => { element.addEventListener('mouseenter', () => { element.style.background = `url('./main/icon/sns_${snsKind[index]}_${ON}.png') no-repeat` }) }) } const mouseLeave = (listArray) => { listArray.forEach((element, index, array) => { element.addEventListener('mouseleave', () => { element.style.background = `url('./main/icon/sns_${snsKind[index]}_${OFF}.png') no-repeat` }) }) }