Hello Armin, hello Forum.
I have the following problem: I have created a way to jump to anchors from the Lay Theme menu on a customer's website. Now I need to fix that solution for sub pages (projects) as well. My workaround was to have a "zurück"-Button in the menu which leads back to the home page. But my customer wants that link to jump to the anchor again…
So my questions are:
-
is it possible to have my menu work on all pages? So no "zurück"-Button would be necessary?
-
or is it possible to make the "zurück"-Button jump to that anchor again?
Here is my code:
<script>
jQuery(document).ready( function() {
jQuery('a').addClass('scroll-to-anch');
});
</script>
<script>
jQuery(document).ready(function(){
jQuery('body').on('click', '.scroll-to-anch', function(event) {
event.preventDefault();
var id = jQuery(this).attr('href');
jQuery('html, body').animate( { scrollTop: jQuery(id).offset().top }, 750 );
});
})
</script>
Thank you and regards!
Arne