views:

65

answers:

0

I'm developing and website and I need it to scroll to an anchor. It needs to be animated, so I decided to use jQuery for that. I tried this:

function goToByScroll(id){
      $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

It works perfectly on the desktop. On Mobile Safari it first goes to the top of the page, then it scrolls to the anchor I want it to scroll to. What's the trick to make it work on Mobile Safari?