0

我使用 libary easing 滚动到 ankor,但是如果我点击第二个 ankor,我的代码不起作用,它会再次跳到顶部,然后根本不起作用。这是我正在处理的主页:

http://www.o-hoerr.de

这是我使用的 jq:

$(function() {

//catch all the clicks on tags
$("a").click(function() {

//check if it has a #
if(this.hash){
//get rid of the # sign
var hash = this.hash.substr(1);

//get the position of the <a name>
var $toElement = $("a[name="+hash+"]");
var toPosition = $toElement.position().top;

//scroll/animate

$("body,html").animate({
  scrollTop : toPosition
},2000,"easeOutExpo");


return false;  
}



});

  if(location.hash) {
  var hash = location.hash;
  window.scroll(0,0);
  $("a[href="+hash+"]").click();

}


});

如果有人能真诚地帮助我就好了 奥利弗

4

1 回答 1

0

尝试在您的名称标签中放置一些东西(文本)或非中断空格

例如:

<a name="Simulight">SSS</a>
<a name="Simulight">&nbsp</a>
于 2014-05-24T00:27:19.080 回答