0

So I've never seen this before and it's driving me crazy. Hope someone else has come across this before and can point me in the right direction. It should be noted that this site was built on the WP platform.

I have a very simple link set up: <a href="site.com/page-1/#div">

The problem is that when I'm on any page, for example "site.com/page-2" nothing happens when I click the link... there's no event being triggered.

If I happen to be on "site.com/page-1" and I click the link it does slide to the appropriate div. But, again, on any other page, the link just doesn't work at all.

Eric Brockman
  • 824
  • 2
  • 10
  • 37

1 Answers1

0
You have to give id in that specific div and there are multiple divs then you can use else if condition and then just put this jquery in footer. Please also add jquery.min.js before it 

$(document).ready(function{
   var hash_val = window.location.hash;
   if(hash_val=="#dienstleistungen"){
     $('html,body').animate({
       scrollTop:$("#dienstleistungen").offset().top-70
     },2000);
   }else if(hash_val=="#uberuns"){
     $('html,body').animate({
       scrollTop:$("#uberuns").offset().top-70
     },2000);
  } 
});
KTrivedi
  • 131
  • 1
  • 5
  • Danke KTrivedi, I'm not looking to have the page scroll to various divs on click. I have a link in the footer, that link needs to work across all pages. Currently it only works if your on the page of that specific div, but if your on a different page the link becomes disabled. Interestingly if I inspect the element and click the link in the inspector it works fine. – Eric Brockman Jun 13 '17 at 14:10