100-project-100-days-website/100_projects/6-Glassmorphism Hover Effects with Magic Line Indicator/app.js
2023-02-27 17:12:09 +03:00
Ask

20 lines
526 B
JavaScript

{5ec6638927d01bd394ce2c798c9159031e8a5ec1 true 526 app.js 0xc001f82310}

let marker = document.querySelector('#marker');
let list = document.querySelectorAll('ul li');
function moveIndicator(e){
marker.style.left = e.offsetLeft+'px';
marker.style.width = e.offsetWidth+'px';
}
list.forEach(link => {
link.addEventListener('mousemove', (e) => {
moveIndicator(e.target);
})
})
function activeLink(){
list.forEach((item) =>
item.classList.remove('active'));
this.classList.add('active');
}
list.forEach((item) =>
item.addEventListener('mouseover', activeLink));