20 lines
526 B
JavaScript
20 lines
526 B
JavaScript
{5ec6638927d01bd394ce2c798c9159031e8a5ec1 true 526 app.js 0xc002a90e00}
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)); |