Archived topic
Anchors in responsive site dont work
17 replies · Started by mike on August 8, 2017
hi there!
i have added anchors in the nav bar, they work fine on desktop, but not on mobile..
any ideas?
thanks
Hi there,
Hmm anchors should work exactly same on desktop and mobile.
Can you link me to the page that's not working? Thanks!
sure
b3u5e.hosts.cx/ - temporary link
i have added anchors in buttons in the site and the same thing - they work only on desktop
id without #
links #example
help?
Can you try adding the full URL along with the anchor as the URL?
tried it. still only works on desktop
it's the third item in the menu
What script are you using for the smooth scroll? If you turn it off, does the link jump to the correct area?
this is it -
the link jumps to the correct area with or without the script
thanks
<script>
jQuery( document ).ready( function( $ ) {
$( document ).on( 'click', '.main-nav li > a:first-child', function( e ) {
var mobile = $( '.menu-toggle' );
if ( mobile.is( ':visible' ) ) {
$( '.menu-toggle').closest( '.main-navigation' ).removeClass( 'toggled' );
$( '.menu-toggle').closest( '.main-navigation' ).attr( 'aria-expanded', $( '.menu-toggle').closest( '.main-navigation' ).attr( 'aria-expanded' ) === 'true' ? 'false' : 'true' );
$( '.menu-toggle').removeClass( 'toggled' );
$( '.menu-toggle').children( 'i' ).addClass( 'fa-bars' ).removeClass( 'fa-close' );
$( '.menu-toggle').attr( 'aria-expanded', $( this ).attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
}
});
});
</script>
would love an answer ;) boss is sitting on my head :/
thank you and have a great evening!
Have you considered just using a plugin like this?: https://en-ca.wordpress.org/plugins/easy-smooth-scroll-links/
hi tom
i dont have a problem with the scroll i think you got my post confused with someone elses.
my anchor links don't function on mobile is my issue
thank you
Sorry what was your code for here? https://generatepress.com/forums/topic/anchors-in-responsive-site-dont-work/#post-362300
Ah, I assumed that code was for smooth scrolling.
Can you remove that code completely? It's not necessary.
i have removed it
the anchor links still don't function on mobile
please help i need my anchors :)