Answer the question
In order to leave comments, you need to log in
Why doesn't navigation through anchor links work?
The menu on the wordpress site is made in the admin panel
on the page itself to go to a specific place
Code for smooth scrolling
<div id="about"></div>
const anchors = document.querySelectorAll('a[href*="#"]')
for (let anchor of anchors) {
anchor.addEventListener('click', function (e) {
e.preventDefault()
const blockID = anchor.getAttribute('href').substr(1)
document.getElementById(blockID).scrollIntoView({
behavior: 'smooth',
block: 'start'
})
})
}
<nav id="site-navigation" class="main-navigation">
<?php
wp_nav_menu(
array(
'theme_location' => 'menu-1',
'menu_id' => 'primary-menu',
)
);
?>
<span class="navTrigger">
<i></i>
<i></i>
<i></i>
</span>
</nav><!-- #site-navigation -->
jQuery("div.menu-menu-1-container").last().addClass("main_list");
jQuery('.navTrigger').click(function () {
jQuery(this).toggleClass('active');
console.log("Clicked menu");
jQuery(".main_list").toggleClass("show_list");
jQuery(".main_list").fadeIn();
});
//Закрытие через onclick сделано так
jQuery('#primary-menu a').on('click', function() {
jQuery( '.navTrigger' ).trigger('click');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question