const marker = document.querySelector('#marker');
const item = document.querySelectorAll('nav .menu li');
const ul = document.querySelector('ul')
let timeout = null
ul.addEventListener('mouseleave', () => {
clearTimeout(timeout)
timeout = setTimeout(() => {
marker.style.width = '0px';
}, 500)
})
function indicator(e){
marker.style.left = e.offsetLeft+'px';
marker.style.width = e.offsetWidth+'px';
}
item.forEach(link =>{
clearTimeout(timeout)
link.addEventListener('mousemove', (e) =>{
indicator(e.target);
})
})
add_filter( 'nav_menu_css_class', 'change_menu_item_css_classes', 10, 3 );
function change_menu_item_css_classes( $classes, $item, $args ) {
if ( $args->menu === 'Main' ) {
$classes = [ 'nav-item' ];
} else {
$classes = [];
}
return $classes;
}
wp_enqueue_script('some_script', 'Путь к скрипту', array(), ВНИМАНИЕ ВЕРСИЯ, false);