1. const triggers = document.querySelectorAll('a');
    2. triggers.forEach(trigger => trigger.addEventListener('mouseenter', highlightLink));
    3. const highlight = document.createElement('span');
    4. highlight.classList.add('highlight');
    5. document.body.appendChild(highlight);
    6. function highlightLink() {
    7. const cords = this.getBoundingClientRect();
    8. const width = cords.width;
    9. const height = cords.height;
    10. const top = cords.top + window.scrollY;
    11. const left = cords.left + window.scrollX;
    12. highlight.style.width = `${width}px`;
    13. highlight.style.height = `${height}px`;
    14. highlight.style.transform = `translate(${left}px, ${top}px)`
    15. }

    image.png

    image.png

    image.png

    image.png

    image.png