0
I created a scroll anchoring with jquery but only works on the same page, how do I work with different pages?
jQuery(document).ready(function($) {
$(".scroll").click(function(event) {
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 800);
});
});
What do you mean by "only works on the same page"? The file of this code is loaded on all pages?
– Ricardo Moraleida
I put the code in the footer file inside a <script> and with the other pages I "pull" the footer file. (It’s just a way I have to make it more organized, but it’s like all the files are just 1). On the home screen, I click on or talk to us and give a scroll to each one, if I click on the "news" page (which is a different page from the home page) and click on "about" I want it to return to the home page and give the scroll to the location where the about.
– Luan Galindo
preventDefault(); it prevents the default behavior of <a>, so I can’t return to my homepage with it. I need that when I’m on another page, the <a> tag has the default behavior and then the anchor script works normally.
– Luan Galindo